mirror of
https://github.com/e107inc/e107.git
synced 2025-08-06 14:46:56 +02:00
fields are marked as required (UI)
This commit is contained in:
@@ -9,8 +9,8 @@
|
|||||||
* Form Handler
|
* Form Handler
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/form_handler.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_handlers/form_handler.php,v $
|
||||||
* $Revision: 1.116 $
|
* $Revision: 1.117 $
|
||||||
* $Date: 2010-02-02 09:04:40 $
|
* $Date: 2010-02-02 13:24:09 $
|
||||||
* $Author: secretr $
|
* $Author: secretr $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -71,11 +71,33 @@ class e_form
|
|||||||
*/
|
*/
|
||||||
protected $_uc;
|
protected $_uc;
|
||||||
|
|
||||||
|
protected $_required_string;
|
||||||
|
|
||||||
function __construct($enable_tabindex = false)
|
function __construct($enable_tabindex = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->_tabindex_enabled = $enable_tabindex;
|
$this->_tabindex_enabled = $enable_tabindex;
|
||||||
$this->_uc = e107::getUserClass();
|
$this->_uc = e107::getUserClass();
|
||||||
|
$this->setRequiredString('<span class="required">* </span>');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get required field markup string
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getRequiredString()
|
||||||
|
{
|
||||||
|
return $this->_required_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set required field markup string
|
||||||
|
* @param string $string
|
||||||
|
* @return e_form
|
||||||
|
*/
|
||||||
|
public function setRequiredString($string)
|
||||||
|
{
|
||||||
|
$this->_required_string = $string;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
function text($name, $value, $maxlength = 200, $options = array())
|
function text($name, $value, $maxlength = 200, $options = array())
|
||||||
@@ -1322,9 +1344,10 @@ class e_form
|
|||||||
* @param string $key
|
* @param string $key
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @param array $attributes field attributes including render parameters, element options - see e_admin_ui::$fields for required format
|
* @param array $attributes field attributes including render parameters, element options - see e_admin_ui::$fields for required format
|
||||||
|
* #param array $required_data required array as defined in e_model/validator
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function renderElement($key, $value, $attributes)
|
function renderElement($key, $value, $attributes, $required_data)
|
||||||
{
|
{
|
||||||
$parms = vartrue($attributes['writeParms'], array());
|
$parms = vartrue($attributes['writeParms'], array());
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
@@ -1721,6 +1744,14 @@ class e_form
|
|||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create form fieldset, called internal by {@link renderCreateForm())
|
||||||
|
*
|
||||||
|
* @param string $id field id
|
||||||
|
* @param array $fdata fieldset data
|
||||||
|
* @param e_admin_model $model
|
||||||
|
* @param boolean $nocontainer ???
|
||||||
|
*/
|
||||||
function renderCreateFieldset($id, $fdata, $model, $nocontainer = false)
|
function renderCreateFieldset($id, $fdata, $model, $nocontainer = false)
|
||||||
{
|
{
|
||||||
$text = vartrue($fdata['fieldset_pre'])."
|
$text = vartrue($fdata['fieldset_pre'])."
|
||||||
@@ -1735,6 +1766,9 @@ class e_form
|
|||||||
<tbody>
|
<tbody>
|
||||||
";
|
";
|
||||||
|
|
||||||
|
// required fields - model definition
|
||||||
|
$model_required = $model->getValidationRules();
|
||||||
|
$required_help = false;
|
||||||
foreach($fdata['fields'] as $key => $att)
|
foreach($fdata['fields'] as $key => $att)
|
||||||
{
|
{
|
||||||
// convert aliases - not supported in edit mod
|
// convert aliases - not supported in edit mod
|
||||||
@@ -1763,13 +1797,30 @@ class e_form
|
|||||||
// type null - system (special) fields
|
// type null - system (special) fields
|
||||||
if($att['type'] !== null && !vartrue($att['noedit']) && $key != $model->getFieldIdName())
|
if($att['type'] !== null && !vartrue($att['noedit']) && $key != $model->getFieldIdName())
|
||||||
{
|
{
|
||||||
|
$required = '';
|
||||||
|
$required_class = '';
|
||||||
|
if(isset($model_required[$key]) || vartrue($att['validate']))
|
||||||
|
{
|
||||||
|
$required = $this->getRequiredString();
|
||||||
|
$required_class = ' class="required-label"'; // TODO - add 'required-label' to the core CSS definitions
|
||||||
|
$required_help = true;
|
||||||
|
if($att['validate'])
|
||||||
|
{
|
||||||
|
// override
|
||||||
|
$model_required[$key] = array();
|
||||||
|
$model_required[$key][] = true === $att['validate'] ? 'required' : $att['validate'];
|
||||||
|
$model_required[$key][] = varset($att['rule']);
|
||||||
|
$model_required[$key][] = $att['title'];
|
||||||
|
$model_required[$key][] = varset($att['error']);
|
||||||
|
}
|
||||||
|
}
|
||||||
$text .= "
|
$text .= "
|
||||||
<tr>
|
<tr>
|
||||||
<td class='label'>
|
<td class='label'>
|
||||||
".defset($att['title'], $att['title']).$label."
|
".$required."<span{$required_class}>".defset($att['title'], $att['title'])."</span>".$label."
|
||||||
</td>
|
</td>
|
||||||
<td class='control'>
|
<td class='control'>
|
||||||
".$this->renderElement($keyName, $model->getIfPosted($valPath), $att)."
|
".$this->renderElement($keyName, $model->getIfPosted($valPath), $att, varset($model_required[$key], array()))."
|
||||||
{$help}
|
{$help}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -1779,9 +1830,15 @@ class e_form
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($required_help)
|
||||||
|
{
|
||||||
|
$required_help = '<div class="form-note">'.$this->getRequiredString().' - required fields</div>'; //TODO - lans
|
||||||
|
}
|
||||||
|
|
||||||
$text .= "
|
$text .= "
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
".$required_help."
|
||||||
".vartrue($fdata['table_post'])."
|
".vartrue($fdata['table_post'])."
|
||||||
<div class='buttons-bar center'>
|
<div class='buttons-bar center'>
|
||||||
";
|
";
|
||||||
|
@@ -157,6 +157,7 @@ div.bbarea.small, .tbox.small, .tbox.helpbox.small { width: 250px !important; }
|
|||||||
.label-note { font-style: italic; }
|
.label-note { font-style: italic; }
|
||||||
.form-note { font-style: italic; }
|
.form-note { font-style: italic; }
|
||||||
.field-spacer.strong { font-weight: bold }
|
.field-spacer.strong { font-weight: bold }
|
||||||
|
.required-label { font-weight: bold }
|
||||||
|
|
||||||
/* Related JS functionality - .autocheck together with .auto-toggle-area (see admin/image.php) */
|
/* Related JS functionality - .autocheck together with .auto-toggle-area (see admin/image.php) */
|
||||||
.auto-toggle-area { width: 280px; cursor: pointer; }
|
.auto-toggle-area { width: 280px; cursor: pointer; }
|
||||||
|
@@ -459,6 +459,7 @@ label { cursor: pointer; }
|
|||||||
.label-note { font-style: italic; }
|
.label-note { font-style: italic; }
|
||||||
.form-note { font-style: italic; }
|
.form-note { font-style: italic; }
|
||||||
.field-spacer.strong { font-weight: bold }
|
.field-spacer.strong { font-weight: bold }
|
||||||
|
.required-label { font-weight: bold }
|
||||||
|
|
||||||
/* Related JS functionality - .autocheck together with .auto-toggle-area (see admin/image.php) */
|
/* Related JS functionality - .autocheck together with .auto-toggle-area (see admin/image.php) */
|
||||||
.auto-toggle-area { width: 280px; cursor: pointer; }
|
.auto-toggle-area { width: 280px; cursor: pointer; }
|
||||||
|
Reference in New Issue
Block a user