Form\Factory can handle config with null elements #4971

merged 1 commit into from Aug 19, 2013


None yet

4 participants


There is an use case, when I have configured form with elements, but I want to disable some elements later in the config of the other module. So I override it with null, but the Form\Factory doesn't recognize it, so it needs a little fix.

grizzm0 commented Aug 16, 2013

Why don't you simply use $form->remove('baz'); instead of setting the element to null?

     * Remove a named element or fieldset
     * @param  string $elementOrFieldset
     * @return FieldsetInterface
    public function remove($elementOrFieldset)
        if (!$this->has($elementOrFieldset)) {
            return $this;

        $entry = $this->byName[$elementOrFieldset];


        if ($entry instanceof FieldsetInterface) {
            return $this;

        return $this;

@grizzm0 Hi, you don't understand. I don't even want to add it. It's about merging configs and creating the form without accessing its instance.

I want to disable some elements later in the config of the other module.

That means statically, not runtime.

ezimuel commented Aug 19, 2013

@bacinsky can you provide an example for that scenario? Why you want to set a form element to null?


@ezimuel I already wrote it. Imagine you have a module with configuration for the form. That form has some elements (maybe only one) I don't want to use in some applications, so I override the config with the null for that element, because it can't be removed by merge. I think this is easy to understand, maybe my bad English cause misunderstanding.

@weierophinney weierophinney added a commit that referenced this pull request Aug 19, 2013
@weierophinney weierophinney Merge branch 'feature/4971' into develop
Close #4971
@weierophinney weierophinney merged commit e32b4c7 into zendframework:develop Aug 19, 2013

1 check passed

default The Travis CI build passed
@bacinsky bacinsky deleted the bacinsky:feature/form-factory-null-element-specification branch Aug 19, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment