Jump to content

Need for a InputfieldSubmit->disable() call?


Recommended Posts

Can't find any reference to a disable() method on the InputfieldSubmit field type...wondering if I should submit a PR to add this method as I'm just getting into using a bunch of inputfields on some process modules and have a need for this. The method would simply add the "disabled" attribute to the button, and add the class "ui-state-disabled", but having a nice disable() method to wrap that up would be something that everyone could use if it were built-in?

I just hesitate to do a PR because I may be missing something, since surely if this was wanted it would have been put in by now??

 

Link to comment
Share on other sites

5 hours ago, J_Szwarga said:

The method would simply add the "disabled" attribute to the button, and add the class "ui-state-disabled"

This is already possible with two lines of code, so I don't think a dedicated method is needed.

$s = $modules->get('InputfieldSubmit');
$s->attr('disabled', true);
$s->addClass('ui-state-disabled');

 

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

That is true, but they do require looking up the class name if you don't already know it. 

I noticed that InputfieldSubmit already has setSmall() (only 1 line of code) and setSecondary().

setDisabled() seemed like it would be consistent with these, just saying.

  • Like 1
Link to comment
Share on other sites

  • 1 year later...
On 3/5/2020 at 10:39 PM, Robin S said:

This is already possible with two lines of code, so I don't think a dedicated method is needed.

$s = $modules->get('InputfieldSubmit');
$s->attr('disabled', true);
$s->addClass('ui-state-disabled');

 

This doesn't work as expected because it only disables the <button> element. But ProcessWire embeds the <button> element within an <a> tag and a click will follow the href nevertheless. Additionally the button element doesn't look disabled... 

I think InputfieldSubmit and it's siblings renders a strange kind of html. <button> within <a></a> is not valid HTML5 and could lead to unexpected behavior. I already filed an issue on GitHub but Ryan told its intended an can't be changed.

Link to comment
Share on other sites

On 12/27/2021 at 6:38 AM, Gadgetto said:

This doesn't work as expected because it only disables the <button> element. But ProcessWire embeds the <button> element within an <a> tag and a click will follow the href nevertheless. Additionally the button element doesn't look disabled... 

I just tested in PW 3.0.191

2021-12-29_163258.png.500b7e1301bb1aea063ec8a10b756a46.png

Result:

2021-12-29_162358.thumb.png.e3edc2bf36ed8c2ee85e9b5119267601.png

No wrapping <a> tag, button is disabled, button is visually identifiable as disabled, works as expected.

  • Like 1
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...