Team,
I'm a total noob hoping someone could help me out on my elgg site. I have a custom form below with an input/location field but always return an "array" value when I click on save:
$tags_label = elgg_echo('Location');
$tags_input = elgg_view('input/location', array(
'name' => 'tags',
'id' => 'blog_tags',
'value' => $vars['tags']
Is it because the location input is too long? e.g. Madison Avenue, New York, NY, United States
It however shows the correct value when i hit Save again...
Result: Location Array
Please shed some light... I read about foreach loop or something but would like to get insights from the pros...
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by Raül Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
Value of field with name tags is converted to be saved as array. Apparently, you try to display it as a value that used to be string. Looks like you mixed up different fields when making custom form. 'Array' is a result of trying to display several values (array) as one.
Thanks for the reponse, Pawel. How do I manage to display the values correctly then?
How do you get the field value in the form action? Are you using $tags = get_input('tags') or something else?
Hi Juho...
I'm trying to display it on a subtitle:
$subtitle .= "<br><b>" . elgg_echo('Location') . "</b> {$blog->tags}";
The above returns an Array value rather than the actual tags values
No, I don't mean how you get the data from an existing blog entity. I'm asking how you're saving the data to it.
Oh, it saves like this, sorry for being noob
$save_button = elgg_view('input/submit', array(
'value' => elgg_echo('save'),
'name' => 'save',
No, that's how you display the form. :)
In which action file or plugin hook do you get the value that was written to the form field?
Do you get the value straight from $_POST or using the function get_input()?
Are you making your own plugin or are you modifying the bundled blog plugin?
sorry,totally lost now.... I'm modying the bundled blog plugin... I just tried to add an additional field.
Ok, first of all never modify the Elgg core but instead create your own plugin that extends the functionality of the bundled blog plugin.
It's not enough that you just add a new field to the form. You also have to add some code that saves the value of the new field.
By default the blog edit form already has a field called "tags". So you propably never even save the field that you think you're saving. Instead you're printing out the contents of the default tags field. And the value of it is an array.
I recommend studying the bundled plugins some more to learn the basics on save and edit data through plugins. Also you should read through the tutorials.
- Previous
- 1
- 2
- Next
You must log in to post replies.