2012-11-21 4 views
5

これは私の書式ですが、正しいと思われるので、この問題は問題にならないでしょう。また、enctypeを削除して、そうでないことを確認しました。

<form action="<?php echo JRoute::_('index.php?option=com_woo&task=hello.create'); ?>" enctype="multipart/form-data" method="post"> 
     <p> 
     Project Name : 
     <input style="width:30%;" name="name" id="name"/> 
     <input style="display:none;" id="user_id" name="user_id" value="<?php echo $user->id;?>"/> 
     <input style="display:none;" id="county" name="county"/> 
     <input style="display:none;" id="state" name="state" /> 
     </p> 
     <button type="submit" class="btn-green" id="select_county">Create Project</button> 
    </form> 

インサイドControllerHello

public function create() 
    { 
     $jinput = JFactory::getApplication()->input; 
     $foo = $jinput->get('state', '', 'filter'); 
     print_r($foo); 
     die; 
    } 

戻り値 "NULL"

任意のアイデア?あなたがフォームのアクションを変更してみてください可能性が

+0

に行くディスプレイ'にセットを持っていますNONE'を、いつでもフォームは、それは空白の入力を送ります提出しますなぜならあなたは価値の代わりに「ヌル」を得ているからです。 – Toretto

答えて

4
$input = new JInput; 
$name = $input->get('name', '', 'post'); 
$country = $input->get('country', '', 'post'); 
// etc. 

次に、あなたは、特定の目的のためにJInputクラスメソッドのシリーズを使用することができます。

// method  integer getInt()  getInt($name, $default = null) Get a signed integer. 
// method  integer getUint()  getUint($name, $default = null) Get an unsigned integer. 
// method  float getFloat()  getFloat($name, $default = null) Get a floating-point number. 
// method  boolean getBool()  getBool($name, $default = null) Get a boolean. 
// method  string getWord()  getWord($name, $default = null) 
// method  string getAlnum()  getAlnum($name, $default = null) 
// method  string getCmd()  getCmd($name, $default = null) 
// method  string getBase64() getBase64($name, $default = null) 
// method  string getString() getString($name, $default = null) 
// method  string getHtml()  getHtml($name, $default = null) 
// method  string getPath()  getPath($name, $default = null) 
// method  string getUsername() getUsername($name, $default = null) 
-2

:あなたのタスクは、それが良いこのように動作可能性があるhello.createない作成と呼ばれているので

<?php echo JRoute::_('index.php?option=com_woo&view=hello&task=create'); 

....

その後、私はいつもちょうど

をしました
$post = JRequest::get('post'); 
print_r($post['state']); 
+3

Joomla 1.7の「JRequest」は推奨されていません。あなたが間違っているわけではありませんが、以下のようなものを使う方が良いでしょう: '$ post = new JInput($ _ POST);' Joomla 2.5以降用) – Lodder

+0

Loddersが正しい。 JInputの詳細はこちらhttp://docs.joomla.org/Retrieving_request_data_using_JInput –

8

あなたはこれを試すことができます - あなたは、特定の配列は、(jform」と呼ばれる取得したい場合は

$input = JFactory::getApplication()->input; 
$post_array = $input->getArray($_POST); 
3

私はJInputで全体の$ _POSTを取得するための最良のオプションは

JFactory::getApplication()->input->post->getArray(); 

だと思います'など)を使用してから

JFactory::getApplication()->input->get('jform', array(), 'ARRAY'); 
0

詳細については、特定のスーパーグローバル

$foo = $jinput->get->get('varname', 'default_value', 'filter'); 

$foo = $jinput->post->get('varname', 'default_value', 'filter'); 

$foo = $jinput->server->get('varname', 'default_value', 'filter'); 

からの値がstate` `のあなたの入力フィールドを1としてRetrieving request data using JInput

関連する問題