并尝试应用我从中学到的东西;
<input autocomplete='off' class='loginInput' tabindex='3' type="text" name="company" id="company" value="<?php echo $_GET["entered"]; ?>" maxlength='50' size="25">
到下面的一段代码(来自我正在构建的J-Cook组件)
<?php
// incident
$field = $fieldSet['jform_incident'] ;
?>
<div class="control-group <?php echo 'field-' . $field->id . $field->responsive; ?>">
<div class="control-label">
<?php echo $field->label; ?>
</div>
<div class="controls">
<?php echo $field->input; ?>
假设代码与上面的示例不同,我尝试了多种方法使表单自动填充
<?php echo $field->input; ?>
运气好的话。如果有人能帮助我,我真的很感激。我现在完全失去了? :(
由于
这是整个页面,其中包含目前提供的更新代码..
<?php
/** ______________________________________________
* o O | |
* ((((( o < Generated with Cook Self Service V2.7 |
* ( o o ) |______________________________________________|
* --------oOOO-----(_)-----OOOo---------------------------------- www.j-cook.pro --- +
* @version 1.02
* @package Safety 101
* @subpackage Incident Actions
* @copyright 2014 Jonathan Bell
* @author JB
* @license
*
* .oooO Oooo.
* ( ) ( )
* -------------\ (----) /----------------------------------------------------------- +
* \_) (_/
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
if (!$this->form)
return;
$fieldSets = $this->form->getFieldsets();
?>
<?php $fieldSet = $this->form->getFieldset('actionsitem.form');?>
<fieldset class="fieldsform form-horizontal">
<?php
// Person responsible
$field = $fieldSet['jform_person_responsible'];
$field->jdomOptions = array(
'list' => $this->lists['fk']['person_responsible']
);
?>
<div class="control-group <?php echo 'field-' . $field->id . $field->responsive; ?>">
<div class="control-label">
<?php echo $field->label; ?>
</div>
<div class="controls">
<?php echo $field->input; ?>
</div>
</div>
<?php
// Date due
$field = $fieldSet['jform_action_due_date'];
?>
<div class="control-group <?php echo 'field-' . $field->id . $field->responsive; ?>">
<div class="control-label">
<?php echo $field->label; ?>
</div>
<div class="controls">
<?php echo $field->input; ?>
</div>
</div>
<?php
// Short description
$field = $fieldSet['jform_action_title'];
?>
<div class="control-group <?php echo 'field-' . $field->id . $field->responsive; ?>">
<div class="control-label">
<?php echo $field->label; ?>
</div>
<div class="controls">
<?php echo $field->input; ?>
</div>
</div>
<?php
// Full description
$field = $fieldSet['jform_full_description'];
?>
<div class="control-group <?php echo 'field-' . $field->id . $field->responsive; ?>">
<div class="control-label">
<?php echo $field->label; ?>
</div>
<div class="controls">
<?php echo $field->input; ?>
</div>
</div>
<?php
// Completed date
$field = $fieldSet['jform_action_completed_date'];
?>
<div class="control-group <?php echo 'field-' . $field->id . $field->responsive; ?>">
<div class="control-label">
<?php echo $field->label; ?>
</div>
<div class="controls">
<?php echo $field->input; ?>
</div>
</div>
<?php
// Action completed
$field = $fieldSet['jform_completed_yn'];
?>
<div class="control-group <?php echo 'field-' . $field->id . $field->responsive; ?>">
<div class="control-label">
<?php echo $field->label; ?>
</div>
<div class="controls">
<?php echo $field->input; ?>
</div>
</div>
<?php
// incident
$field = $fieldSet['jform_incident'] ;
?>
<div class="control-group <?php echo 'field-' . $field->id . $field->responsive; ?>">
<div class="control-label">
<?php echo $field->label; ?>
</div>
<div class="controls">
<?php
$current_field = $field->input;
$current_field_input = str_replace('/>', '', $current_field);
$current_field_input = str_replace('>', '', $current_field);
?>
<?php echo $current_field_input; ?> autocomplete='off' value="<?php echo (isset($_GET["entered"])) ? $_GET["enter"] : ""; ?>"/>
</div>
</div>
</fieldset>
答案 0 :(得分:0)
JFormField类具有内置的预设和默认选项(这些是不同的,默认情况下,如果您的字段留空,则会保存),您可以在表单的XML(文件或字符串)中设置这些选项。 API还允许您更改表单的属性或添加新属性。如果使用API,整个代码将更容易编写和读取。看一下核心CMS中的一些示例,您将看到许多示例。 以下是一些典型示例,显示了add,set和get:
$fieldset->addAttribute('description', 'COM_CATEGORIES_ITEM_ASSOCIATIONS_FIELDSET_DESC');
$field->addAttribute('edit', 'true');
$form->setFieldAttribute('ordering', 'disabled', 'true');
$fieldName = $field->getAttribute('name');