Skip to content

Commit

Permalink
add textarea option
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanedemotte committed Mar 7, 2019
1 parent e224367 commit 063f445
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion assets/js/origin-acf-field-slug.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
.prop('readonly', true)
.css({ opacity: .7, backgroundColor: '#eee' })

this.$ref = $('input[name="acf[' + this.ref + ']"]')
this.$ref = $('[name="acf[' + this.ref + ']"]')
this.$visibility = $('input[name="visibility"]')

this.pattern = this.$input.data('preview')
Expand Down
18 changes: 18 additions & 0 deletions fields/origin-acf-field-unique.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,21 @@ function render_field( $field ) {
$class .= ' origin_unique_is_slug';

?>

<?php if($field['origin_unique_is_textarea']): ?>
<textarea
type="text"
class="<?php echo $class ?>"
name="<?php echo esc_attr($field['name']) ?>"
><?php echo esc_attr($field['value']) ?></textarea>
<?php else: ?>
<input
type="text"
class="<?php echo $class ?>"
name="<?php echo esc_attr($field['name']) ?>"
value="<?php echo esc_attr($field['value']) ?>" />
<?php endif; ?>

<?php
}

Expand All @@ -47,6 +57,14 @@ function render_field_settings( $field ) {
'ui' => 1,
'name' => 'origin_unique_is_slug',
));

acf_render_field_setting( $field, array(
'label' => 'Use textarea',
'instructions' => '',
'type' => 'true_false',
'ui' => 1,
'name' => 'origin_unique_is_textarea',
));
}

function input_admin_enqueue_scripts() {
Expand Down

0 comments on commit 063f445

Please sign in to comment.