Zum Inhalt springen

Dropdown-Box für Datumeingabe

Erstellt am 7. Mai 2008 · 7 Antworten · letzte Antwort am 7. Mai 2008

Tags: PHP, Frage

silverzone ·

Hallo

In meiner Extension soll der FE-User in einer Form sein Geburtsdatum eintragen. Ich will das so machen, dass er zuerst den Tag, Monat und dann das Jahr auswählen muss. Mit einer Dropdown box.

Leider weiss ich nicht, wie ich das mache. Habs mal so versucht, aber es klappt nicht, respk. die Box bleibt leer.

$tag=array();
$tag[]=1;
$tag[]=2;
$tag[]=3;
$tag[]=4;

$form=array();
$form[]=array($this->pi_getLL('name'), $this->prefixId . '[inline][name]=input , 25');
//$form[]=array($this->pi_getLL('geburtsdatum'), $this->prefixId. '[inline][geburtsdatum]=input , 25');
$form[]=array($this->pi_getLL('geburtsdatum'), $this->prefixId. '[inline][geburtsdatum]=select , '. $tag );
$form[]=array($this->pi_getLL('email'), $this->prefixId. '[inline][email]=input , 25');
$form[]=array('',$this->prefixId.'[submit]=submit', $this->pi_getLL('submit'));

Kann mir jemand die korrekte Syntax sagen, repsk. wo ich das nachlesen kann?

Gruss Stefan

saschae ·

Dein kompletter code würde sicher weiter helfen. denn was du da machst hat ja noch garnichts mit dem dropdown zu tun. du baust dir ja nur ein (komisches?) array zusammen

silverzone ·

Hi
Danke für die Antwort.

Eben, ich weiss nicht wie das funktionieren soll.

Hier der Code:

<?php
/***************************************************************
*  Copyright notice
*
*  (c) 2008 Stefan <blabla@blabla.com>
*  All rights reserved
*
*  This script is part of the TYPO3 project. The TYPO3 project is
*  free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  The GNU General Public License can be found at
*  http://www.gnu.org/copyleft/gpl.html.
*
*  This script is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

require_once(PATH_tslib.'class.tslib_pibase.php');


/**
 * Plugin 'inline' for the 'smc_inline' extension.
 *
 * @author	Stefan <s.meile@blackgrape.ch>
 * @package	TYPO3
 * @subpackage	tx_smcinline
 */
class tx_smcinline_pi1 extends tslib_pibase {
	var $prefixId      = 'tx_smcinline_pi1';		// Same as class name
	var $scriptRelPath = 'pi1/class.tx_smcinline_pi1.php';	// Path to this script relative to the extension dir.
	var $extKey        = 'smc_inline';	// The extension key.
	var $pi_checkCHash = true;
	
	/**
	 * The main method of the PlugIn
	 *
	 * @param	string		$content: The PlugIn content
	 * @param	array		$conf: The PlugIn configuration
	 * @return	The content that is displayed on the website
	 */
	
	
	 
	function main($content,$conf)	{
		$this->conf=$conf;
		$this->pi_setPiVarDefaults();
		$this->pi_loadLL();
		
    // Layout beziehen

if (!$conf["formLayout"]) {
  $formLayout='<div style="clear:both; padding:3px;"><div style="float:right;">###FIELD###</div>###LABEL###</div>'; 
} else { 
  $formLayout=$conf['formLayout'];
}

if (!$conf["formWrap"]) {
  $formWrap='<div style="width:350px;">|</div>'; 
}
  else { 
  $formWrap=$conf['formWrap'];
}

// Formularfelder zusammensetzen
$tag=array();
$tag[]=1;
$tag[]=2;
$tag[]=3;
$tag[]=4;

debug($tag);




$form=array();
$form[]=array($this->pi_getLL('name'), $this->prefixId . '[inline][name]=input , 25');
//$form[]=array($this->pi_getLL('geburtsdatum'), $this->prefixId. '[inline][geburtsdatum]=input , 25');
$form[]=array($this->pi_getLL('geburtsdatum'), $this->prefixId. '[inline][geburtsdatum]=select | 1' );
$form[]=array($this->pi_getLL('email'), $this->prefixId. '[inline][email]=input , 25');
$form[]=array('',$this->prefixId.'[submit]=submit', $this->pi_getLL('submit'));

debug($form);

// Formularkonfiguration festlegen

$fconf=array( 'type'=>t3lib_div::getIndpEnv('REQUEST_URI'),  'layout'=>$formLayout, );

// Formular zeichnen

$content.=$this->cObj->wrap($this->cObj->FORM($fconf,$form), $formWrap);


if (is_array($this->piVars['inline'])) {
  foreach($this->piVars['inline'] as $a => $b) {
      $insertArr[$a]=htmlspecialchars($b);
  }

  $insertArr['crdate']=time();
  $insertArr['tstamp']=time();
  $insertArr['hidden']='0';
  $insertArr['pid']=37;
 // $insertArr['relation']=$cfield;
  $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_smcinline_users',$insertArr);
}
	
		return $this->pi_wrapInBaseClass($content);
	}
}



if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/smc_inline/pi1/class.tx_smcinline_pi1.php'])	{
	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/smc_inline/pi1/class.tx_smcinline_pi1.php']);
}

?>

Ich hab mich noch das angeschaut:

https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/ContentObjects/Index.html

Aber das hilft mir auch nicht weiter. eigentlich muss ich nur wissen, wie die Zeile richtig wäre:

$form[]=array($this->pi_getLL('geburtsdatum'), $this->prefixId. '[inline][geburtsdatum]=select | 1' );

Damit ich eine Auswahl von 1- 31 erhalte.

Grüsse Stefan

silverzone ·

ok habs nun geschafft:

$form[]=array($this->pi_getLL('tag'), $this->prefixId. 'inline_tag id=select','1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31' );

Nun würde ich aber diesen Feldern noch ein ID-Tag mitgeben. Da scheitere ich nun schon wieder #angry# #angry#

Gruss Stefan

saschae ·

hast dus mal mit

$form[]=array($this->pi_getLL('geburtsdatum'), $this->prefixId. '[inline][geburtsdatum]=select | 1,2,3,4,5,6,7,8,9,10,11,12,13...' );

probiert?

saschae ·

hehe ok 😉
hm bei dem id tag kann ich dir auch nicht weiter helfen... keine ahnung wie das form cobject das macht... aber vllt hilft ja ein blick in den quellcode weiter...