Hot answers tagged

5

The first method looks for elements that start with the name that you have specified: <input type="hidden" name="nameOfArray[test][1]" value="test" /> <input type="hidden" name="nameOfArray[]" value="test" /> <input type="hidden" name="nameOfArray[test][]" value="test" /> <input type="hidden" name="nameOfArray[tester][yes]" value="test" ...


5

This should work: $values = $app->input->getArray(array('data'=>'array')); echo $values['data']['server']; Please see I did not mention post variable specifically, because this can retrieve both get and post values. If you need to get a value from a specific super global, such as post, you can use something like $app->input->post You can ...


4

You could try: $data = $input->post->get('data', array(), 'ARRAY'); $server = $data['server']; Haven't a playground to test this in, but I think it works.


3

Your original coding attempt is repeatedly overwriting the $dataPoints variable inside of the loop -- this is why you only see the last iteration's data. To create the desired multidimensional array directly from the query's result set, here is the way to use column aliases and Joomla's query building syntax. $db = JFactory::getDbo(); $query = $db->...


3

So you are counting all submissions 1 user has and you want to display that message when the user has 30, 60, 90, ... submissions? That doesn't make much sense to me but the solution would be to change if ($counter = $max){ to if ($counter % $max == 0) { In computing, the modulo operation finds the remainder after division of one number by another ...


2

I haven't tested this so I could be wrong. But if I rightly remember, a protected object cannot be retrieved by $field->fieldparams->options. Instead, you'll need to use: $options = $field->fieldparams->get('options'); foreach ($options as $option) { echo $option->name; echo $option->value; } Again, I haven't tested this and have ...


2

The field options are a registry object so if you've already got the field you can grab all the options with something like: $field_options = $field->fieldparams->toArray(); print_r that and you'll see the structure it provides which you can then just foreach through.


2

If you dumped the $_POST in your helper's ajax method you would see that those empty arrays don't hit the server. Joomla's input object is entirely dependent on retrieving the values from $_POST. JQuery ajax doesn't pass empty arrays, see this for example further reading: https://stackoverflow.com/questions/9397669/jquery-ajax-jsonp-how-to-actually-send-an-...


2

It is a json encoded string. $images = json_decode($item->images);


2

Syntax for modifying the array would be something like $db->setQuery($query); $rows =$db->loadAssocList(); foreach ($rows as &$row) // & to give a reference, not copy, to the row in rows { ++$MaxID; $row['id'] = $row['id'] + $MaxID; // Add $MaxID to $row[id] .... // possibly other modifications? }


2

Been a while since I used repeatable form fields (deprecated and subform fields should be used instead), but if I rightly remember, the repeatable form fields response format was a little different. It grouped each column in an array rather than each row. So what you'll need to do is define a function to group the values by key: function groupByKey($array) {...


2

It's how Repeatable field stores its data. Pick a field to iterate over and use its key to access value of another field: foreach ($carousel_images['carouselimage'] as $key => $image) { // do something clever for each of the images '<img src="' . $image .'"><p>' . $carousel_images['carouselcaption'][$key] . '</p>'; } ...


2

PHP array_values returns an array - that's why you get "array" printed out. Most likely if you deal with an array and want to make it a string, then you are after implode($separator, $array); http://php.net/manual/en/function.implode.php For example, for a comma separated string you can do: implode(',', $field->rawvalue); But you have to make clear ...


1

I found a solution that seams to work. Creating the Form without the usual jform control class like this: // $form = $this->loadForm('my_comp.examplegroup', 'examplegroup', array('control' => 'jform', 'load_data' => $loadData)); $form = $this->loadForm('my_comp.examplegroup', 'examplegroup', array('control' => '', 'load_data' => $loadData)...


1

To construct your tag data in the format that can be echoed into the html, you must convert the data into a string. array_values() does not convert an array to a string, it reindexes (assigns new numeric keys starting from 0) the array. Assuming you wish to generate a string with comma-separated values, you should use implode(',', $field->rawvalue) like ...


1

First, you need to repair your damaged form html // see the missing closing square bracket on each of your name attr ---↓-------------------↓-↓ ↓ ↓ ↓ echo '<div class="vm_kampe"><input type="hidden" name="kid['.$row->id.'← ↓ ↓ <div ...


1

I've figured it out with the help of someone on the Joomla DEV Google Groups (details): I did not have my custom field dancer_id added to the jform array like so: <input id="dancer_id" type="checkbox" name="jform[dancer_id][]" value="2261" checked> Once I did so, it all worked. Details linked above.


1

Have you tried retrieving the form input directly without using JFilterInput? Try this: replace: $filter = JFilterInput::getInstance(); with: $dancers = $input->get('dancer','','array'); you can then do $data['dancer_id'] = implode(",", $dancers); From there you can finish up with your save methods


Only top voted, non community-wiki answers of a minimum length are eligible