Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding ability to specify a field as required to add a span to the html

$yf->test('name')->set('required', TRUE) // will add a * by default
or
$yf->test('name')->set('required', 'some text') // will add the string 'some text'
  • Loading branch information...
commit dea57bd8be725928551e7ebc1a8c1d7cd373e8ab 1 parent 4c5546c
Lorenzo Pisani authored
9 views/yform/themes/default/choice/checkboxGroup.php
View
@@ -3,7 +3,14 @@
<fieldset class="yform-item yform-checkboxGroup">
<?php if( ! empty($label)): ?>
- <legend><?php echo $label; ?></legend>
+ <legend>
+ <?php echo $label; ?>
+ <?php if ($object->get('required') !== FALSE): ?>
+
+ <span class="required"><?php echo ($object->required === TRUE)?'*':$object->required; ?></span>
+
+ <?php endif; ?>
+ </legend>
<?php endif; ?>
<?php foreach ($object->options() as $option): ?>
9 views/yform/themes/default/choice/radioGroup.php
View
@@ -3,7 +3,14 @@
<fieldset class="yform-item yform-radioGroup">
<?php if( ! empty($label)): ?>
- <legend><?php echo $label; ?></legend>
+ <legend>
+ <?php echo $label; ?>
+ <?php if ($object->get('required') !== FALSE): ?>
+
+ <span class="required"><?php echo ($object->required === TRUE)?'*':$object->required; ?></span>
+
+ <?php endif; ?>
+ </legend>
<?php endif; ?>
<?php foreach ($object->options() as $option): ?>
9 views/yform/themes/default/choice/select.php
View
@@ -3,7 +3,14 @@
<div class="yform-item yform-password<?php echo empty($errors) ? '' : ' errors'; ?>">
<?php if ( ! empty($label)): ?>
- <label for="<?php echo Arr::get($attributes, 'id'); ?>" ><?php echo $label; ?></label>
+ <label for="<?php echo Arr::get($attributes, 'id'); ?>" >
+ <?php echo $label; ?>
+ <?php if ($object->get('required') !== FALSE): ?>
+
+ <span class="required"><?php echo ($object->required === TRUE)?'*':$object->required; ?></span>
+
+ <?php endif; ?>
+ </label>
<?php endif; ?>
<select <?php echo HTML::attributes($attributes); ?>>
9 views/yform/themes/default/input/password.php
View
@@ -2,7 +2,14 @@
<!-- BEGIN YForm_Password Element -->
<div class="yform-item yform-password<?php echo empty($errors) ? '' : ' errors'; ?>">
<?php if ( ! empty($label)): ?>
- <label for="<?php echo Arr::get($attributes, 'id'); ?>" ><?php echo $label; ?></label>
+ <label for="<?php echo Arr::get($attributes, 'id'); ?>" >
+ <?php echo $label; ?>
+ <?php if ($object->get('required') !== FALSE): ?>
+
+ <span class="required"><?php echo ($object->required === TRUE)?'*':$object->required; ?></span>
+
+ <?php endif; ?>
+ </label>
<?php endif; ?>
<input <?php echo HTML::attributes($attributes); ?>/>
9 views/yform/themes/default/input/text.php
View
@@ -3,7 +3,14 @@
<div class="yform-item yform-text<?php echo empty($errors) ? '' : ' errors'; ?>">
<?php if ( ! empty($label)): ?>
- <label for="<?php echo Arr::get($attributes, 'id'); ?>" ><?php echo $label; ?></label>
+ <label for="<?php echo Arr::get($attributes, 'id'); ?>" >
+ <?php echo $label; ?>
+ <?php if ($object->get('required') !== FALSE): ?>
+
+ <span class="required"><?php echo ($object->required === TRUE)?'*':$object->required; ?></span>
+
+ <?php endif; ?>
+ </label>
<?php endif; ?>
<input <?php echo HTML::attributes($attributes); ?>/>
9 views/yform/themes/default/input/textarea.php
View
@@ -2,7 +2,14 @@
<!-- BEGIN YForm_Textarea Element -->
<div class="yform-item yform-textarea<?php echo empty($errors) ? '' : ' errors'; ?>">
<?php if ( ! empty($label)): ?>
- <label for="<?php echo Arr::get($attributes, 'id'); ?>" ><?php echo $label; ?></label>
+ <label for="<?php echo Arr::get($attributes, 'id'); ?>" >
+ <?php echo $label; ?>
+ <?php if ($object->get('required') !== FALSE): ?>
+
+ <span class="required"><?php echo ($object->required === TRUE)?'*':$object->required; ?></span>
+
+ <?php endif; ?>
+ </label>
<?php endif; ?>
<textarea <?php echo HTML::attributes($attributes); ?>><?php echo HTML::chars($object->value); ?></textarea>
9 views/yform/themes/default/input/upload.php
View
@@ -3,7 +3,14 @@
<div class="yform-item yform-upload<?php echo empty($errors) ? '' : ' errors'; ?>">
<?php if ( ! empty($label)): ?>
- <label for="<?php echo Arr::get($attributes, 'id'); ?>" ><?php echo $label; ?></label>
+ <label for="<?php echo Arr::get($attributes, 'id'); ?>" >
+ <?php echo $label; ?>
+ <?php if ($object->get('required') !== FALSE): ?>
+
+ <span class="required"><?php echo ($object->required === TRUE)?'*':$object->required; ?></span>
+
+ <?php endif; ?>
+ </label>
<?php endif; ?>
<input <?php echo HTML::attributes($attributes); ?>/>
Please sign in to comment.
Something went wrong with that request. Please try again.