Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added button twig function #383

Merged
merged 5 commits into from
Jul 15, 2015
Merged

Added button twig function #383

merged 5 commits into from
Jul 15, 2015

Conversation

bigfoot90
Copy link
Contributor

The function

{{ button() }}

Will render to

<button class="btn btn-default btn-md" type="submit"></button>

The function

{{ button_link() }}

Will render to

<a href="#" class="btn btn-default btn-md"></a>

You can also customize the buttons with options.

{{ button({
            'id': 'test_button',
            'label': 'Test',
            'tooltip': 'Test',
            'class': 'my-class',
            'icon': 'check',
            'type': 'sucess',
            'size': 'sm',
            'submit': false,
            'attr': {
                'data-confirm': 'Are you sure?'
            },
}) }}

Will render to

<button id="test_button" class="btn btn-sucess btn-sm my-class" type="button" title="Test" data-confirm="Are you sure?"><i class="fa fa-check"></i> Test</button>

The function

{{ button_link({
            'label': 'Test',
            'icon': 'check',
            'type': 'sucess',
            'size': 'sm',
            'attr': {
                'id': 'test_button',
                'class': 'my-class',
                'href': 'example.com',
                'data-confirm': 'Are you sure?',
                'title': 'Test',
            },
}) }}

Will render to

<a id="test_button" href="example.com" class="btn btn-sucess btn-sm my-class" title="Test" data-confirm="Are you sure?"><i class="fa fa-check"></i> Test</a>

@bigfoot90
Copy link
Contributor Author

@florianeckerstorfer ping

@bigfoot90
Copy link
Contributor Author

@florianeckerstorfer Done ;)

@florianeckerstorfer
Copy link
Member

Thanks. I just noticed one last thing. Could you add the space to the individual variables instead of the $button? Before id, href, etc. Makes the generated HTML code nicer.

@bigfoot90
Copy link
Contributor Author

Updated PR post message

@bigfoot90
Copy link
Contributor Author

Question: some times I need to add an extra attribute to the buttons data-confirm="Continue?", can I add the code here?

@florianeckerstorfer
Copy link
Member

If you do it in a way that it is general, like attr in Symfony form fields.

@bigfoot90
Copy link
Contributor Author

Done

@florianeckerstorfer
Copy link
Member

Mmh, I think you should take into account the other attributes as well. For example, what happens if a user sets the [attr][class] attribute.

@bigfoot90
Copy link
Contributor Author

You should not set the class inside attrubutes but in function options directly.

But I will rework attributes soon.

@bigfoot90
Copy link
Contributor Author

Now?

@florianeckerstorfer
Copy link
Member

Thanks.

florianeckerstorfer pushed a commit that referenced this pull request Jul 15, 2015
Add button twig function
@florianeckerstorfer florianeckerstorfer merged commit c33f6ef into braincrafted:develop Jul 15, 2015
@bigfoot90 bigfoot90 deleted the button branch July 15, 2015 13:17
@bigfoot90
Copy link
Contributor Author

Can you tell me when will you put new tag with this function?

@bigfoot90
Copy link
Contributor Author

Updated first post.
The function button_link with option was not updated from last commit

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