Jump to content
Mike Rockett

Secondary buttons in a form

Recommended Posts

How do I accomplish the following in a form?

post-2289-0-39881300-1420809437_thumb.pn

Buttons as shown in the Fields listing

I need the buttons on the left and right. After having a look at the code for InputfieldButton, I don't think it's possible. But there has to be a decent way of doing it...

Share this post


Link to post
Share on other sites

Unless I render each one out to a string, and then send the complete string back? But then how would I get them to float to the right?

Share this post


Link to post
Share on other sites

Simply have a look in ProcessTemplate. There's simply no extra markup, it's just css.

#export_button, #import_button {
  float: right;
  margin-left: 0.25em;
}

Share this post


Link to post
Share on other sites

Can't you just set the class ?

$button = wire('modules')->get('InputfieldButton');
$button->attr('class', 'ui-button ui-widget ui-state-default ui-corner-all align-me-right'); 
 
Didn't test it but looks like: $button->addClass('align-right'); should do the trick.
Edited by Martijn Geerts
  • Like 2

Share this post


Link to post
Share on other sites

Ah, right (was definitely not looking in the right places)... Would be nice if it was built in: $button->addClass('ui-button-float-right').

  • Like 1

Share this post


Link to post
Share on other sites

It is built in. Martijn was close right. You can do this:

$button = $this->modules->get('InputfieldButton'); 
$button->attr('id', 'button_create'); 
$button->attr('value', $this->_('Create New')); 
$button->attr('href', './edit/'); 
$button->class .= ' my-float-right-class';//note: concatenation + space

PW will add the other inbuilt button classes.

//See a cleaner alternative below...

Edited by kongondo
  • Like 2

Share this post


Link to post
Share on other sites

Indeed it is cleaner...updated my post.. Martijn was right  :D

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...