Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Form] Unified rendering of errors for nested elements
- Loading branch information
Showing
12 changed files
with
73 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/form_row.html.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
<div> | ||
<?php echo $view['form']->label($form, isset($label) ? $label : null) ?> | ||
<?php if (!$compound): ?> | ||
<?php echo $view['form']->errors($form) ?> | ||
<?php endif ?> | ||
<?php echo $view['form']->errors($form) ?> | ||
<?php echo $view['form']->widget($form) ?> | ||
</div> |
1 change: 0 additions & 1 deletion
1
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/form_rows.html.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
<?php echo $view['form']->errors($form) ?> | ||
<?php foreach ($form as $child) : ?> | ||
<?php echo $view['form']->row($child) ?> | ||
<?php endforeach; ?> |
7 changes: 7 additions & 0 deletions
7
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/form_widget_compound.html.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
<div <?php echo $view['form']->renderBlock('widget_container_attributes') ?>> | ||
<?php if (!$form->hasParent() && $errors): ?> | ||
<tr> | ||
<td colspan="2"> | ||
<?php echo $view['form']->errors($form) ?> | ||
</td> | ||
</tr> | ||
<?php endif ?> | ||
<?php echo $view['form']->renderBlock('form_rows') ?> | ||
<?php echo $view['form']->rest($form) ?> | ||
</div> |
72 changes: 21 additions & 51 deletions
72
src/Symfony/Bundle/FrameworkBundle/Resources/views/FormTable/form_errors.html.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,21 @@ | ||
<?php if (!$compound): ?> | ||
<?php if ($errors): ?> | ||
<ul> | ||
<?php foreach ($errors as $error): ?> | ||
<li><?php | ||
if (null === $error->getMessagePluralization()) { | ||
echo $view['translator']->trans( | ||
$error->getMessageTemplate(), | ||
$error->getMessageParameters(), | ||
'validators' | ||
); | ||
} else { | ||
echo $view['translator']->transChoice( | ||
$error->getMessageTemplate(), | ||
$error->getMessagePluralization(), | ||
$error->getMessageParameters(), | ||
'validators' | ||
); | ||
}?></li> | ||
<?php endforeach; ?> | ||
</ul> | ||
<?php endif ?> | ||
<?php else: ?> | ||
<?php if (count($errors) > 0): ?> | ||
<tr> | ||
<td colspan="2"> | ||
<?php if ($errors): ?> | ||
<ul> | ||
<?php foreach ($errors as $error): ?> | ||
<li><?php | ||
if (null === $error->getMessagePluralization()) { | ||
echo $view['translator']->trans( | ||
$error->getMessageTemplate(), | ||
$error->getMessageParameters(), | ||
'validators' | ||
); | ||
} else { | ||
echo $view['translator']->transChoice( | ||
$error->getMessageTemplate(), | ||
$error->getMessagePluralization(), | ||
$error->getMessageParameters(), | ||
'validators' | ||
); | ||
}?></li> | ||
<?php endforeach; ?> | ||
</ul> | ||
<?php endif ?> | ||
</td> | ||
</tr> | ||
<?php endif; ?> | ||
<?php endif; | ||
<?php if ($errors): ?> | ||
<ul> | ||
<?php foreach ($errors as $error): ?> | ||
<li><?php | ||
if (null === $error->getMessagePluralization()) { | ||
echo $view['translator']->trans( | ||
$error->getMessageTemplate(), | ||
$error->getMessageParameters(), | ||
'validators' | ||
); | ||
} else { | ||
echo $view['translator']->transChoice( | ||
$error->getMessageTemplate(), | ||
$error->getMessagePluralization(), | ||
$error->getMessageParameters(), | ||
'validators' | ||
); | ||
}?></li> | ||
<?php endforeach; ?> | ||
</ul> | ||
<?php endif ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/Symfony/Bundle/FrameworkBundle/Resources/views/FormTable/form_widget_compound.html.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
<table <?php echo $view['form']->renderBlock('widget_container_attributes') ?>> | ||
<?php if (!$form->hasParent()): ?> | ||
<?php echo $view['form']->errors($form) ?> | ||
<?php endif ?> | ||
<?php echo $view['form']->renderBlock('form_rows') ?> | ||
<?php echo $view['form']->rest($form) ?> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters