Reputation: 3875
I am making an edit form in wordpress. This is my code. My trim()
function is not working.
<div class = "input-group">
<label for = "business_meta_title"><?php _e('Meta Title', 'wcd');
?></label>
<textarea type="text" name="business_meta_title" id="business_meta_title" class="form-control">
<?php echo trim(get_field('business_meta_title', $deal_id)); ?>
</textarea>
</div>
<div class="input-group">
<label for="business_meta_description"><?php _e('Meta Description', 'wcd'); ?></label>
<textarea type="text" name="business_meta_description" id="business_meta_description" class="form-control">
<?php echo trim(get_field('business_meta_description', $deal_id)); ?>
</textarea>
</div>
<div class="input-group">
<label for="business_meta_keywords"><?php _e('Meta Keywords', 'wcd'); ?></label>
<textarea type="text" name="business_meta_keywords" id="business_meta_keywords" class="form-control">
<?php echo trim(get_field('business_meta_keywords', $deal_id)); ?>
</textarea>
</div>
I am getting output like this.
Any thoughts? What should I do?
Upvotes: 2
Views: 969
Reputation: 21681
I suggest you two changes point which may solve your issue:
1. If you working with wordpress then please use wordpress provided wp_trim_words instead trim()
.
2. Remove spacing between value and <textarea>
tag
wp_trim_words()
function trims text to a certain number of words and returns the trimmed text.
Upvotes: 0
Reputation: 16117
Use without spaces between value in tag as:
<textarea type="text" name="business_meta_keywords" id="business_meta_keywords" class="form-control"><?php echo trim(get_field('business_meta_keywords', $deal_id)); ?></textarea>
Upvotes: 1
Reputation: 1171
Please re-write your textareas
by having no spaces in them, trim
works fine but you are adding the extra spaces after opening textarea
tag in your HTML:
<div class = "input-group">
<label for = "business_meta_title"><?php _e('Meta Title', 'wcd');
?></label>
<textarea type="text" name="business_meta_title" id="business_meta_title" class="form-control"><?php echo trim(get_field('business_meta_title', $deal_id)); ?></textarea>
</div>
<div class="input-group">
<label for="business_meta_description"><?php _e('Meta Description', 'wcd'); ?></label>
<textarea type="text" name="business_meta_description" id="business_meta_description" class="form-control"><?php echo trim(get_field('business_meta_description', $deal_id)); ?></textarea>
</div>
<div class="input-group">
<label for="business_meta_keywords"><?php _e('Meta Keywords', 'wcd'); ?></label>
<textarea type="text" name="business_meta_keywords" id="business_meta_keywords" class="form-control"><?php echo trim(get_field('business_meta_keywords', $deal_id)); ?></textarea>
</div>
Upvotes: 2