Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
How to display error message right below the control
  • I am developing application using fuelphp.  After validating the form field in server side I can shoe the error messages using   Session::set_flash('error', $val->error()); . I can show the error messages on top of my forms.

     I have got 20 fields in form I want to display error messages right below the fields.
    How do i do it ?
    How do i get the error message by passing the field name ?
  • HarroHarro
    Accepted Answer
    That depends on how you have setup your form.

    If you use a fieldset, you can configure this, and it will happen automatically. You also don't have to create validations manually.

    If you handcoded your HTML, you need to access errors individually. $val->error() returns an associative array with the name of the input field as key.

    Note that validation objects are quite large, so if you want to store them in the session, perhaps you should convert it to a normal array first:

    $errors = $val->error();
    foreach ($error as $field => $valobj)
    {
        $errors[$field] = (string) $valobj;
    }
    Session::set_flash('error', $errors);
  • Thank you for the tips . It worked for my custom form

Howdy, Stranger!

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

In this Discussion