du248227 2014-10-29 00:16
浏览 22

使用joomla函数将逗号分隔值插入textarea

I have a custom component,

One of my xml form fields has multiple=true

It gives me the ability to select more than one item from another table via an sql query

However...

I can not work out how to insert it?

protected function loadFormData(){

    $app  = JFactory::getApplication();
    $data = $app->getUserState('tourbookings.edit.tour.data', array());

    if(empty($data)){
        $data = $this->getItem();   

        // i added this but no luck
        $data->itinerary = explode(',', $data->itinerary); 

        var_dump($data);

        if($this->getState('tour.id') == 0){
        $data->set('catid', $app->input->getInt('catid',      $app->getUserState('com_tourbookings.tours.filter.category_id')));
        }
    }

    return $data;
}

My var_dump looks like this:

object(JObject)#169 (32) { 
["_errors":protected]=> array(0) { } 
["id"]=> string(1) "2" 
["itinerary"]=> array(2) { [0]=> string(1) "1" [1]=> string(1) "2" } 
} 

If anyone could help shed light on this i would be grateful :)

note: Joomla provides simple docs on how to create the xml form fields for a custom component but its not so cl;ear how to insert arrays from select lists etc..

My xml that produces a field that lets me select more than one value

<field
    name="itinerary"
    type="sql"
    label="Itinerary"
    description="COM_TOURBOOKINGS_TOURS_FIELD_ITINERARY_DESC"
    size="40"
    query="SELECT id AS value, name FROM #__bs_itinerarys"
    key_field="value"
    value_field="name"
    translate="0"
    onList="1"
    onForm="1"
    required="0"
    multiple="1"
    validate=""
    class="input"       
/>

cheers Jonny

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 安装svn网络有问题怎么办
    • ¥15 Python爬取指定微博话题下的内容,保存为txt
    • ¥15 vue2登录调用后端接口如何实现
    • ¥65 永磁型步进电机PID算法
    • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
    • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
    • ¥15 如何处理复杂数据表格的除法运算
    • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
    • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
    • ¥15 latex怎么处理论文引理引用参考文献