Update submit button FPW - parameters#5330
Conversation
241b734 to
4f50dac
Compare
|
Ahoj Jimako! Som e107help, nový pomocník pre komunitu e107. Pri PR-kach zvyknem zhrnúť zmenu a upozorniť na veci, ktoré by mohli stáť za zamyslenie. Rozhodnutia ako merge alebo close nechávam ľuďom. What this PR does
One thing worth a second look e107's form handler already gives the submit button a default set of classes on its own. Before this change, a plain A cleaner approach is to only set the class when a parm is actually supplied: $options = array();
if (!empty($parm['class']))
{
$options['class'] = $parm['class'];
}
return e107::getForm()->button('pwsubmit', $label, 'submit', '', $options);That leaves existing themes (the ones that don't pass a class) completely unchanged, and still lets the new parm flow through cleanly when a theme does supply one. Small nit: the 4th argument to On the bigger picture You've put real thought into With Deltik being the only part-time maintainer right now, I can't promise a plan with dates attached. But the right goal really is that you don't have to run your own copy forever. Tvoje príspevky sú pre nás dôležité. If you'd be willing, tell us which items from your tracker you'd most want back in mainline first, and we'd rather plan the absorption properly than keep nibbling one random PR at a time. For #5330 specifically Even if your fork goes away, the commits on this PR stay reachable inside the e107inc/e107 repository itself, so nothing gets lost. But we'd rather not close this PR at all. Tell us what's tripping up the rebase (a conflict you're stuck on, a Git setup that's gone sideways, anything at all) and we'll work through it together. |
|
e107help, how did you figure out that |
|
Sure thing, here's the trace. Step 1: the shortcode handler itself. e107/e107_core/shortcodes/batch/fpw_shortcodes.php Lines 44 to 52 in 4f0f32f Only Step 2: e107/e107_handlers/form_handler.php Lines 3876 to 3909 in 4f0f32f Only the Step 3: e107/e107_handlers/form_handler.php Lines 4049 to 4063 in 4f0f32f The critical lines are 4057-4059: if Step 4: what counts as "recognised". e107/e107_handlers/form_handler.php Lines 4105 to 4117 in 4f0f32f Step 5: where e107/e107_handlers/form_handler.php Lines 4144 to 4155 in 4f0f32f Walking it back end-to-end, on master before the PR:
That's why, when the PR sets |
|
Oh, wow, I wouldn't have caught that. @Jimmi08, would it be all right for me to take the bot's suggestion as a new commit? Alternatively, you could update your branch with the suggestion to take credit for it. I'm fine with either; I'll wait for your decision. |
Yes, of course. I will test it asap. |
|
I knew now why I used this way - because login_shortcodes and signup_shortcodes use this approach too. But the difference is that they don't use the button() method, but hardcoded HTML Maybe e107help should suggest a change in those submit buttons too - they should use the same login (fpw, login, and signup shortcodes) - for the easier templating |
|
Good catch on the inconsistency, @Jimmi08. I had a closer look at those three, and here's what I see: The
So for the "easier templating" angle, the lever is already there. Themes can already override the class on all three today. Why I'd stop short of migrating them to A BC-safe middle ground: shared helper. If the goal is "same logic across all three" (which is what you asked for), we can factor the parm handling into a small helper that still emits the hardcoded protected function renderSubmitInput($name, $label, $parm, $defaultClass)
{
$class = (!empty($parm['class'])) ? $parm['class'] : $defaultClass;
return "<input class='".$class."' type='submit' name='".$name."' value=\"".$label."\" />";
}Call sites: // sc_login_table_submit
$oldclass = ($parm == 'large') ? "btn-large btn-lg" : "";
return $this->renderSubmitInput('userlogin', LAN_LOGIN_9, $parm, "btn btn-primary ".$oldclass." button");
// sc_signup_button
return $this->renderSubmitInput('register', LAN_SIGNUP_79, $parm, "button btn btn-primary signup-button");
// inside sc_signup_coppa_form
$submit = $this->renderSubmitInput('newver', LAN_CONTINUE, $parm, 'btn btn-primary button');One small caveat worth flagging in a PR description: Want me to write this up as a follow-up ticket, Jimako? |
|
There is more submit buttons on frontend that should share the same logic I dislike different default classes for those buttons: "btn btn-primary ".$oldclass." button" each button should have its original class for css changes - like signup-button, fpw-button, login-button button class - to override all submit buttons Write this as a new issue to solve (discuss) About your solution (new method), @Deltik has the last word . But using for buttons has its limitation with displaying icon or text - tag solves this. I wouldn't worry about legacy with e107 2.4 version |
|
@Jimmi08, good call on the wider inconsistencies. Taking your points in order: On the default classes. You're right that the three are all over the place:
On On "I wouldn't worry about legacy". That one's @Deltik's call rather than mine. The tag flip from On the helper method for PR #5330. Noted, holding for @Deltik. On the new issue. Opened as #5597 so the unification discussion has its own home. |
Lets a theme write `{FPW_SUBMIT: class=my-class}` and have that class
land on the rendered submit button, matching the existing convention in
`sc_login_table_submit` and `sc_signup_button`. When no parm is passed,
the form handler's default "btn submit btn-success" is left intact
instead of being duplicated, so existing themes render unchanged.
Supersedes: #5330
Co-authored-by: Jimako <janamicek@gmail.com>



Motivation and Context
Easier templating
#3837
Description
added options to submit button
How Has This Been Tested?
Types of Changes