Validate if inline edit is less than current number

Validate if inline edit is less than current number

ztaylor1990ztaylor1990 Posts: 27Questions: 10Answers: 0

Hi, I am trying to implement a validator into my server-side script and I keep getting the same error.
Fatal error: Uncaught Error: Class 'Validate' not found in /httpdocs/Editor-1.9.2/lib/Editor.php:972 Stack trace: #0 /httpdocs/Editor-1.9.2/lib/Editor.php(700): DataTables\Editor->_process(Array) #1 /var/www/vhosts/fcsanalytics.com/httpdocs/bidtool/php/point-point_table_serverside.php(78): DataTables\Editor->process(Array) #2 {main} thrown in /httpdocs/Editor-1.9.2/lib/Editor.php on line 972

I have a scenario where the user can not submit a number greater than their previously submitted number.

use
    DataTables\Editor,
    DataTables\Editor\Field,
    DataTables\Editor\Format,
    DataTables\Editor\Mjoin,
    DataTables\Editor\Options,
    DataTables\Editor\Upload,
    DataTables\Editor\Validate,
    DataTables\Editor\ValidateOptions;
$sql2 = "SELECT * FROM ".$customer_name."_".$bidyear."_rfp_point_point";
$result = mysqli_query($conn, $sql2);   
$columns = array_keys($result->fetch_assoc());             

$table = $customer_name.'_'.$bidyear.'_rfp_point_point';
$editor = Editor::inst( $db, $table ,'1');

foreach ($columns as $i) {
$editor->field(Field::inst( $table.".".$i ));
}
      
$editor->field(Field::inst( $customer_name.'_'.$bidyear.'_carrier_list_rd1_point_point.bid_one_currency' ));
$editor->field(Field::inst( $customer_name.'_'.$bidyear.'_carrier_list_rd1_point_point.bid_one_mode' ));
$editor->field(Field::inst( $customer_name.'_'.$bidyear.'_carrier_list_rd1_point_point.bid_one_rpm' ))
    ->validator('Validate::maxNum', array(
        'min' => 0.00,
        'max' => $customer_name.'_'.$bidyear.'_carrier_list_rd1_point_point.bid_one_rpm',
        'message' => 'Please enter a number 0 and your round 1 rate'
    ) );
$editor->field(Field::inst( $customer_name.'_'.$bidyear.'_carrier_list_rd1_point_point.bid_one_minimum_charge' ));
$editor->field(Field::inst( $customer_name.'_'.$bidyear.'_carrier_list_rd1_point_point.bid_one_asset_broker' ));

$editor->field(Field::inst( $customer_name.'_'.$bidyear.'_carrier_list_rd1_point_point.bid_one_equipment_type' ));
$editor->field(Field::inst( $customer_name.'_'.$bidyear.'_carrier_list_rd1_point_point.bid_one_capacity' ));

$editor->leftJoin( $customer_name.'_'.$bidyear.'_carrier_list_rd1_point_point', $customer_name.'_'.$bidyear.'_carrier_list_rd1_point_point.lane_id', '=', $customer_name.'_'.$bidyear.'_rfp_point_point.1', 'AND', $customer_name.'_'.$bidyear.'_carrier_list_rd1_point_point.carrier_name', '=', $customer_name );

$editor->process( $_POST );
$editor->json();

Can someone please assist me with this?

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    'max' => $customer_name.'_'.$bidyear.'_carrier_list_rd1_point_point.bid_one_rpm',

    This won't work I'm afraid. The validator expects a number to test against, not an SQL statement. You would need to use a custom validator if you want to query the database for the current value and validate against that.

    Regards,
    Allan

This discussion has been closed.