Skip to content

Conversation

@rn0
Copy link
Member

@rn0 rn0 commented Nov 25, 2013

There is method AbstractResource::getResourceFormOptions which return form options array.

This way we can customize form html ID:

    public function getResourceFormOptions()
    {
        return array(
            'attr' => array(
                'id' => 'process-form',
            )
        );
    }

Due to part of template below, some part of customization made in getResourceFormOptions is lost.

<form action="{{ path('fsi_admin_resource', {element: element.id}) }}" method="post" {{ form_enctype(form) }} class="form-horizontal">

I propose to use form_start twig function.

@norberttech
Copy link
Contributor

Yes, this looks like a nice improvement. But I think we should also modify form rendering in create/edit actions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

attr should be passed as a string 'attr'.

What do you think about following code?

{{ form_start(form, { action: path('fsi_admin_resource', { element: element.id }), 'attr': { class: "form-horizontal" }|merge(form.vars.attr) }) }}

This should give us possibility to overwrite or add class from form configuration.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

attr should be passed as a string 'attr'.

If that is coding convention in project then I'm OK with that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a convention but in almost every example in symfony docs array keys are passed as a string.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about following code?

Nice.

@rn0
Copy link
Member Author

rn0 commented Nov 25, 2013

Modified form rendering in create/edit/delete templates.

@norberttech
Copy link
Contributor

Looks good :) I would like to wait with this PR for #57

norberttech added a commit that referenced this pull request Dec 2, 2013
Passing form options to form template
@norberttech norberttech merged commit 2b4af2c into fsi-open:master Dec 2, 2013
@norberttech
Copy link
Contributor

Thanks @rn0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants