# Form check before render

**URL:** <https://discourse.laminas.dev/t/form-check-before-render/1579>\
**Category:** Components & MVC\
**Created:** [May 6, 2020, 6:38am UTC](https://discourse.laminas.dev/t/form-check-before-render/1579 "2020-05-06T06:38:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![giorg](https://avatars.discourse-cdn.com/v4/letter/g/2bfe46/32.png) [@giorg](https://discourse.laminas.dev/u/giorg)\
**Post date:** [May 6, 2020, 6:38am UTC](https://discourse.laminas.dev/t/form-check-before-render/1579/1 "2020-05-06T06:38:15Z")

</div>

Hello,  
newbie here. I am rendering a form fieldset:

```
public function __construct()
{
    // we want to ignore the name passed
    parent::__construct('ProductDocumentationLanguageFieldset');

    $dh = DoctrineHelper::getInstance();

    $this -> setHydrator(new DoctrineHydrator($dh -> getEntityManager(), 'Application\Entity\Language\ProductDocumentationLanguage', false))
          -> setObject(new ProductDocumentationLanguage());
    $this->setAllowedObjectBindingClass('Application\Entity\Language\ProductDocumentationLanguage');

    $this->add(array(
        'name' => 'id',
        'type' => 'hidden',
    ));

    $this->add(array(
        'name' => 'group_id',
        'type' => 'hidden',
    ));

    $this->add(array(
        'name' => 'product_detail',
        'type' => 'hidden',
    ));

    $this->add(array(
        'type' => 'DoctrineModule\Form\Element\ObjectSelect',
        'name' => 'language',
        'attributes' => array(
            'class' => 'form-control'
        ),
        'options' => array(
            'label' => 'Product language',
            'object_manager' => $dh->getEntityManager(),
            'target_class' => 'Application\Entity\Language',
            'property' => 'name',
            'empty_option' => 'Select language',
            'is_method' => true,
            'find_method' => array(
                'name' => 'findAll',
            ),
        ),
    ));
}

```

this will show me 2 dropdowns on frontend. I need to check, for each of the 2 dropdowns, the selected value on another db table, and if present set the dropdown disabled. How can achieve this?

Thanks a lot

---

<div class="post-metadata">

**Author:** ![giorg](https://avatars.discourse-cdn.com/v4/letter/g/2bfe46/32.png) [@giorg](https://discourse.laminas.dev/u/giorg)\
**Post date:** [May 7, 2020, 7:54am UTC](https://discourse.laminas.dev/t/form-check-before-render/1579/2 "2020-05-07T07:54:30Z")

</div>

nobody on this topic? really need help with this.  
thanks

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [May 7, 2020, 8:32am UTC](https://discourse.laminas.dev/t/form-check-before-render/1579/3 "2020-05-07T08:32:57Z")

</div>

I think some informations are missing to help here.

> [@giorg](#):
>
> this will show me 2 dropdowns on frontend.

Your form class contains only one `Select` element?!

> [@giorg](#):
>
> I need to check, for each of the 2 dropdowns, the selected value on another db table, and if present set the dropdown disabled.

The select element is disabled in the frontend after the reload or what is your goal here?

---

<div class="post-metadata">

**Author:** ![giorg](https://avatars.discourse-cdn.com/v4/letter/g/2bfe46/32.png) [@giorg](https://discourse.laminas.dev/u/giorg)\
**Post date:** [May 7, 2020, 9:10am UTC](https://discourse.laminas.dev/t/form-check-before-render/1579/4 "2020-05-07T09:10:23Z")

</div>

hi,  
thanks for your answer. This class implements InputFilterProviderInterface, and generates 2 dropdowns. My goal is to have attribute disabled if the current selected value satisfy a condition (query on another table).

thanks

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [May 7, 2020, 9:23am UTC](https://discourse.laminas.dev/t/form-check-before-render/1579/5 "2020-05-07T09:23:13Z")

</div>

> [@giorg](#):
>
> My goal is to have attribute disabled if the current selected value satisfy a condition (query on another table).

In the frontend via JavaScript or after the form was submited?

---

<div class="post-metadata">

**Author:** ![giorg](https://avatars.discourse-cdn.com/v4/letter/g/2bfe46/32.png) [@giorg](https://discourse.laminas.dev/u/giorg)\
**Post date:** [May 7, 2020, 9:40am UTC](https://discourse.laminas.dev/t/form-check-before-render/1579/6 "2020-05-07T09:40:28Z")

</div>

nope, this form is loaded from db, from a model: there is a table languages, and this model I’m getting has a foreign key on languages. so the first time I open this model, I select a language and save. Works like a charm. But the second time (and from now on) I open this model, have to check if the selected value I’ve chosen before, is present in another table (actually another db, I call a rest api), and if yes, the dropdown must be disabled. Hove I have been clear enough 🙂  
Thanks a lot!
