field().update puts all options in same line

field().update puts all options in same line

antonis80antonis80 Posts: 18Questions: 8Answers: 0

Hi all

I am using ajax call to php script to obtain the select options of a given field:

editor6.on( 'preOpen', function ( e, o, action ) {
if(action !== 'remove')
{
var request = $.ajax({
url: 'http://127.0.0.1:8080/Food%20Ball/backup/FoodBall%20Site%20form_dt_2/Food%20Ball%20Site/get_admin_data.php?type=subcategories',
cache: false,
dataType: 'json',
contentType: 'application/json; charset=utf-8',
type: 'get',
success: function(data) {
$subs = data.options;
editor6.field('sub_category').update([data.options]);
//$('#menu_datatables1').DataTable().ajax.reload();
}
});
}
});

However, the options result fetched from my php script via json appear all in the same line.

Any solution to this will be appreciated
Thank you

Answers

  • allanallan Posts: 63,831Questions: 1Answers: 10,518 Site admin

    What is inside data.options?

    Allan

  • antonis80antonis80 Posts: 18Questions: 8Answers: 0

    RESULT in data.options send from php:

    "test 1", "test 2", "test 3" and this is what appears in the single option within the field as well.

    i also tried:

    { label: '".$row['sub_category']."', value: '".$row['sub_category']."' }
    { label: '".$row['sub_category']."', value: '".$row['sub_category']."' }
    { label: '".$row['sub_category']."', value: '".$row['sub_category']."' }
    { label: '".$row['sub_category']."', value: '".$row['sub_category']."' }

    but again the same result in the same row select option (single select option)

  • allanallan Posts: 63,831Questions: 1Answers: 10,518 Site admin

    Are you able to give me a link to the page please? You can send me a private message by clicking my name above and then "Send message". I'm afraid I don't know what would cause the problem you are describing and would need to be able to debug the page to understand and resolve the issue.

    Allan

This discussion has been closed.