Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Search form
  • Hello!

    I have an ORM model Advert. In this class I set some fields as ruquired (for example brand_id (it has relations with another ORM model, but it doesn't matter)). When I create new advert - requerid fields are need.

    Now I want to make search form. If I use Advert model, required fields are shown as required. But it is not correct. User should be able to fill fields that ge wants How can I "unset" the requirement?

    Or I should go another way?
  • HarroHarro
    Accepted Answer
    I assume this is because you're using a Fieldset in combination with add_model?

    You can remove a rule using the fieldset field's delete_rule() method:

    $fieldset->field('brand_id')->delete_rule('required');

    I usually do it the other way around, fields that are not always required are defined as optional in the model, and I'll add the "required" rule in the controller when needed.
  • Thank you!

Howdy, Stranger!

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

In this Discussion