J_Szwarga Posted March 5, 2020 Share Posted March 5, 2020 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 More sharing options...
Robin S Posted March 5, 2020 Share Posted March 5, 2020 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'); 1 Link to comment Share on other sites More sharing options...
J_Szwarga Posted March 18, 2020 Author Share Posted March 18, 2020 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. 1 Link to comment Share on other sites More sharing options...
Gadgetto Posted December 26, 2021 Share Posted December 26, 2021 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 More sharing options...
Robin S Posted December 29, 2021 Share Posted December 29, 2021 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 Result: No wrapping <a> tag, button is disabled, button is visually identifiable as disabled, works as expected. 1 Link to comment Share on other sites More sharing options...
Gadgetto Posted December 29, 2021 Share Posted December 29, 2021 @Robin Ssorry, the behavior I described is only true when using InputfieldButton. InputfieldSubmit has no surrounding <a></a> tags. Your hint only works with InputfieldSubmit. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now