-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Conversation
Please retain passing of the label to the partial, it's helpful to avoid having to manually handle translation, etc. Here's the partial I currently use showing use cases for the label and custom vars; <div class="row<?php echo $errors ? " error" : "" ?>">
<div class="three mobile-one columns">
<?php if (isset($label)) : ?>
<?php echo $label ?>
<?php endif; ?>
</div>
<div class="nine mobile-three columns">
<?php echo $element ?>
<?php if ($errors): ?>
<small><?php echo $errors ?></small>
<?php endif; ?>
</div>
</div> |
@Slamdunk have you had a chance to try and incorporate the feedback from @davidwindell ? Do you need assistance? I'd like to get this in for RC2 if we can, but I'm also aiming for RC2 later today... |
I've passed the translated label to the partial. Regarding the custom variables, I'm not very happy to take the partial template approach like you did. Once you set the partial template, it will be always taken by next calls till someone will reset it to null, and this is okay because it's likely the behaviour we want: to set a custom row template for all. But variables are different: if we set them in one row, we have to reset them in the next row with your old code, and i'm not okay with that. A different solution may be to modify @weierophinney to me there are only 3 possibilities:
|
The build is passing as of ZF2 PR https://travis-ci.org/zendframework/zf2/builds/6927579 The fail refers to the mine https://travis-ci.org/Slamdunk/zf2/builds/6927574 (I don't know why one passes and the other doesn't) |
I think 2 makes sense -- it brings the primary intent into place, and, as you noted, is tested. It's unlikely the API will need to change in the future in terms of basic usage. @davidwindell can then work on (3) later. :) |
FormRow: enable partial rendering
Guys, what about having a default view partial, so that this can be set in a bootstrap (for example), and then specifying a partial for a specific form row would use it for that row only, and then reset it to the default? |
Thanks @Slamdunk for finishing this one off, for those looking in the future, an updated example of the partial I show above that produces a Foundation CSS style formRow; <?php $errors = $this->formelementerrors($element); ?>
<div class="row<?php echo $errors ? " error" : "" ?>">
<div class="three mobile-one columns">
<?php if ($element->getLabel()) : ?>
<?php echo $this->formlabel($element) ?>
<?php endif; ?>
</div>
<div class="nine mobile-three columns">
<?php echo $this->formelement($element); ?>
<?php if ($errors): ?>
<small><?php echo $errors ?></small>
<?php endif; ?>
</div>
</div> in your module.php; 'formrow' => function ($sm) {
$formRow = new FormRowHelper();
$formRow->setPartial('partials/formrow.phtml');
return $formRow;
} |
And another thing: Element errors are needlessly rendered when using a partial. Suggestion: Move:
... below the partial rendering, and change:
... to:
|
@glen-84 Can you create a PR for that, please? |
#4441 ... I also checked $this->renderErrors before rendering. |
Issue #4405
This is what I think @davidwindell intended to do, a way to use custom partial in the form row helper.
If you're thinking about why using a partial within a helper instead of directly call the partial helper in a view, I think that this is a way to easy override a lot of views leaving the
$this->formRow($element);
code in them.The view has every helper it heeds to render whatever you want, so we can call the
return $this->view->[...]
immediately, instead of after some logic.