Skocz do zawartości
"Idzie nowe..." - o zmianach i nie tylko ×
Przeniesienie zakupów z IPS Marketplace / Moving bought items from IPS Marketplace ×

Pobieranie wartości pola formMultiDropdown


Gość Wolen
Przejdź do rozwiązania Rozwiązane przez DawPi,

Rekomendowane odpowiedzi

Witam, mam taki kod

    public function add() 
    {
        $LoadEditor = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite' );
        $editor = new $LoadEditor();
        $edytor = $editor->show( 's_desc', array(
						'type'                          => 'medium',
						'minimize'                      => FALSE,
						'height'                        => 150,
						'autoSaveKey'           => '',
						'warnInfo'                      => NULL,
						'modAll'                        => FALSE,
						'recover'                       => FALSE,
						'noSmilies'                     => FALSE,
						'isHtml'                        => FALSE,
						'isRte'                         => NULL,
						'isTypingCallBack'      => '',
						'delayInit'                     => FALSE,
						'editorName'            => NULL
						) );
		if($this->request['addMember_form'] == 'add')
		{ 
			if(!empty($this->request['field_s_name']) && !empty($this->request['field_s_serverid']) && !empty($this->request['field_s_flags']) && !empty($this->request['field_s_api']))
			{
				$this->DB->insert( 'wd_services', array(
                                                        'name' => $editor->process( $_POST['field_s_name'] ),
                                                        'desc' => $editor->process( $_POST['s_desc'] ),
                                                        'serverid' => $editor->process( $_POST['field_s_serverid'] ),
                                                        'flags' => $editor->process( $_POST['field_s_flags'] ),
                                                        'api' => $editor->process( $_POST['field_s_api'] )
														) );
				$this->registry->output->redirect( $this->settings['base_url'].'&module=services&section=services', 'Pomyslnie dodano usluge.', 5 );
			}
			else
			{
				$this->registry->output->redirect( $this->settings['base_url'].'&module=services&section=services&do=add', 'Uzupelnij wszystkie pola.', 5 );
			}
		} 
	    $this->DB->build( array( 'select' => 'id, name', 'from' => 'wd_servers_test', 'order' => 'id' ) );
		$this->DB->execute();

        while ( $row = $this->DB->fetch() )
        {
            $s_array[] = array( $row['id'], $row['name'] );
        }

		$this->registry->output->html .= $this->html->addservice($edytor, $s_array);
    }

i

    public function addservice($edytor, $s_array)
	{
		$IPBHTML = "";
		//--starthtml--//
		
		$form['s_name']			= $this->registry->output->formInput( 'field_s_name', '', 'field_s_name' );
		$form['s_desc']				= $this->registry->output->formtextarea( 'field_s_desc', '', 'field_s_desc' );
		$form['s_serverid']			= $this->registry->output->formMultiDropdown( 'field_s_serverid', $s_array );
        $form['s_flags']			= $this->registry->output->formInput( 'field_s_flags', '', 'field_s_flags' );
        $form['s_api']			= $this->registry->output->formInput( 'field_s_api', '', 'field_s_api' );
		
	

	$IPBHTML .= <<<HTML
<div class='section_title'>
	<h2>{$this->lang->words['wd_add_service']}</h2>
</div>
HTML;

$IPBHTML .= <<<HTML
<form action='{$this->settings['base_url']}module=services&section=services&do=add' method='post' id='addPunished' name='addPunished'>
	<input type='hidden' name='addMember_form' value='add' />
	<div class='acp-box'>
		<h3>{$this->lang->words['wd_add_service']}</h3>
		<table class='ipsTable double_pad'>
			<tr>
				<td class='field_title'><strong class='title'>{$this->lang->words['wd_s_name']}</strong></td>
				<td class='field_field'>{$form['s_name']} <div class="desctext">{$this->lang->words['wd_s_name_desc']}</div></td>
			</tr>
			<tr>
				<td class='field_title'><strong class='title'>{$this->lang->words['wd_s_desc']}</strong></td>
				<td class='field_field'>{$edytor} <div class="desctext">{$this->lang->words['wd_s_desc_desc']}</div></td>
			</tr>
			<tr>
				<td class='field_title'><strong class='title'>{$this->lang->words['wd_serverid']}</strong></td>
				<td class='field_field'>{$form['s_serverid']}<div class="desctext">{$this->lang->words['wd_serverid_desc']}</div></td>
			</tr>
			<tr>
				<td class='field_title'><strong class='title'>{$this->lang->words['wd_s_flags']}</strong></td>
				<td class='field_field'>{$form['s_flags']} <div class="desctext">{$this->lang->words['wd_s_flags_desc']}</div></td>
			</tr>
 			<tr>
				<td class='field_title'><strong class='title'>{$this->lang->words['wd_s_api']}</strong></td>
				<td class='field_field'>{$form['s_api']} <div class="desctext">{$this->lang->words['wd_s_flags_desc']}</div></td>
			</tr>
   {$this->request['field_s_serverid']}
		</table>
		<div class="acp-actionbar">
			<input type='submit' value='Dodaj' class="button primary" />
		</div>
	</div>	
</form>		
		
HTML;
		//--endhtml--//
		return $IPBHTML;

	}

Mój problem polega na tym, że nie za bardzo mam pomysł jak pobrać wartości z pola "s_serverid". To znaczy, pole to jest mulliDropdownem i mam w nim 2 pola jedno pole Test1 ma id 1, drugie pole ma nazwę Test2 i ma id 2. Jak zaznaczę oba pola do bazy wrzuca mi tylko id ostatniego, a chciałbym, żeby wrzucało id obu pól w formacie 1, 2, 3 (te cyfry to są id z tych pól). Ma ktoś pomysł jak to zrobić? Wystarczy samo nakierowanie.

Odnośnik do komentarza
Udostępnij na innych stronach

  • Manager
  • Rozwiązanie
$this->registry->output->formMultiDropdown( 'field_s_serverid[]', $s_array );

A przy zapisie:

implode( ',', $this->request['field_s_serverid'] )

intermedia - profesjonalne rozwiązania Invision Power Board

---

Chcesz uzyskać szybko i sprawnie pomoc? Uzupełnij wersję i adres w profilu.

Odnośnik do komentarza
Udostępnij na innych stronach

Gość
Ten temat został zamknięty. Brak możliwości dodania odpowiedzi.
  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...

Powiadomienie o plikach cookie

Umieściliśmy na Twoim urządzeniu pliki cookie, aby pomóc Ci usprawnić przeglądanie strony. Możesz dostosować ustawienia plików cookie, w przeciwnym wypadku zakładamy, że wyrażasz na to zgodę.