start POC of field types forms
This commit is contained in:
parent
365f7f530f
commit
f5d9806f0e
|
@ -266,6 +266,11 @@ class TAINACAN_REST_Fields_Controller extends TAINACAN_REST_Controller {
|
|||
|
||||
if($request['context'] === 'edit'){
|
||||
$item_arr['current_user_can_edit'] = $item->can_edit();
|
||||
ob_start();
|
||||
$item->get_field_type_object()->form();
|
||||
$form = ob_get_clean();
|
||||
$item_arr['edit_form'] = $form;
|
||||
|
||||
}
|
||||
|
||||
return $item_arr;
|
||||
|
|
|
@ -47,29 +47,33 @@ class Category extends Field_Type {
|
|||
// TODO: form incomplete and not tested
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<label><?php echo __('Category','tainacan'); ?></label><br/>
|
||||
<small><?php echo __('Select the category','tainacan'); ?></small>
|
||||
</td>
|
||||
<td>
|
||||
<select name="taxonomy_id">
|
||||
<?php foreach ($taxonomies as $tax): ?>
|
||||
|
||||
<option value="<?php echo $tax->get_db_identifier(); ?>" <?php selected($this->get_option('taxonomy_id'), $tax->get_db_identifier()); ?> ><?php echo $tax->get_name(); ?></option>
|
||||
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<label><?php echo __('Allow creation of new terms','tainacan'); ?></label><br/>
|
||||
<small><?php echo __('If checked, users may create new terms for this category, otherwise they can only selected from existing terms.','tainacan'); ?></small>
|
||||
</td>
|
||||
<td>
|
||||
<input type="checkbox" name="allow_new_terms" <?php checked(true, $this->get_option('allow_new_terms')); ?> >
|
||||
<label>Allow</label>
|
||||
</td>
|
||||
</tr>
|
||||
<div class="field">
|
||||
<label class="label">
|
||||
<?php _e('Category','tainacan'); ?>
|
||||
</label>
|
||||
|
||||
<div class="control">
|
||||
<div class="select">
|
||||
<select name="field_type_options[taxonomy_id]">
|
||||
<?php foreach ($taxonomies as $tax): ?>
|
||||
|
||||
<option value="<?php echo $tax->get_db_identifier(); ?>" <?php selected($this->get_option('taxonomy_id'), $tax->get_db_identifier()); ?> ><?php echo $tax->get_name(); ?></option>
|
||||
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<div class="control">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" name="field_type_options[allow_new_terms]" <?php checked(true, $this->get_option('allow_new_terms')); ?> >
|
||||
Allow
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class Checkbox extends Field_Type {
|
|||
*/
|
||||
|
||||
public function render( $itemMetadata ){
|
||||
$options = ( isset( $this->options['options'] ) ) ? $this->options['options'] : '';
|
||||
$options = $this->get_option('options');
|
||||
return '<tainacan-checkbox options="'.$options.'"
|
||||
field_id ="'.$itemMetadata->get_field()->get_id().'"
|
||||
item_id="'.$itemMetadata->get_item()->get_id().'"
|
||||
|
@ -41,7 +41,7 @@ class Checkbox extends Field_Type {
|
|||
<small><?php echo __('Insert the options, separate by lines for the field value','tainacan'); ?></small>
|
||||
</td>
|
||||
<td>
|
||||
<textarea name="field_type_checkbox[options]"><?php echo ( isset( $this->options['options'] ) ) ? $this->options['options'] : ''; ?></textarea>
|
||||
<textarea name="field_type_options[options]"><?php echo $this->get_option('options'); ?></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
|
|
|
@ -33,7 +33,7 @@ class Date extends Field_Type {
|
|||
* generate the fields for this field type
|
||||
*/
|
||||
public function form(){
|
||||
$approx_date = ( $this->options['approximate_date'] ) ? $this->options['approximate_date'] : '';
|
||||
$approx_date = $this->get_option('approximate_date');
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
|
@ -41,7 +41,7 @@ class Date extends Field_Type {
|
|||
<small><?php echo __('Allow format approximate date','tainacan'); ?></small>
|
||||
</td>
|
||||
<td>
|
||||
<?php Helpers\HtmlHelpers::radio_field( $approx_date, 'field_type_date[approximate_date]' ) ?>
|
||||
<?php Helpers\HtmlHelpers::radio_field( $approx_date, 'field_type_options[approximate_date]' ) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
|
|
|
@ -22,7 +22,7 @@ class Radio extends Field_Type {
|
|||
*/
|
||||
|
||||
public function render( $itemMetadata ){
|
||||
$options = ( isset( $this->options['options'] ) ) ? $this->options['options'] : '';
|
||||
$options = $this->get_option('options');
|
||||
return '<tainacan-radio
|
||||
options="' . $options . '"
|
||||
field_id ="'.$itemMetadata->get_field()->get_id().'"
|
||||
|
@ -42,7 +42,7 @@ class Radio extends Field_Type {
|
|||
<small><?php echo __('Insert the options, separate by lines for the field value','tainacan'); ?></small>
|
||||
</td>
|
||||
<td>
|
||||
<textarea name="field_type_radio[options]"><?php echo ( isset( $this->options['options'] ) ) ? $this->options['options'] : ''; ?></textarea>
|
||||
<textarea name="field_type_options[options]"><?php echo $this->get_option('options'); ?></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
|
|
|
@ -22,7 +22,7 @@ class Selectbox extends Field_Type {
|
|||
*/
|
||||
|
||||
public function render( $itemMetadata ){
|
||||
$options = ( isset( $this->options['options'] ) ) ? $this->options['options'] : '';
|
||||
$options = $this->get_option('options');
|
||||
return '<tainacan-selectbox
|
||||
options="' . $options . '"
|
||||
field_id ="'.$itemMetadata->get_field()->get_id().'"
|
||||
|
@ -42,7 +42,7 @@ class Selectbox extends Field_Type {
|
|||
<small><?php echo __('Insert the options, separate by lines for the field value','tainacan'); ?></small>
|
||||
</td>
|
||||
<td>
|
||||
<textarea name="field_type_selectbox[options]"><?php echo ( isset( $this->options['options'] ) ) ? $this->options['options'] : ''; ?></textarea>
|
||||
<textarea name="field_type_options[options]"><?php echo $this->get_option('options'); ?></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
|
|
Loading…
Reference in New Issue