Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Validation and numeric values
  • I have the following code:

    $max = 100;
    $field = $fieldset->add(
    "coupon",
    "Gutschein",
    array("type" => "number", "min" => 0, "max" => $max),
    array('required', "numeric")
    );
    $field->add_rule('numeric_max', array($max));

    If I now enter for example 10 into the input field, I get the error, that the value should be only 100. Has this something to do with "it does not check or cast the input to a numeric value so any non-numeric value will be considered to be zero. Use the PHP function is_numeric to check that first."

    How can I achieve this?
  • Ok, I found the problem. 

    $field->add_rule('numeric_max', $max);
    instead of
    $field->add_rule('numeric_max', array($max));

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion