5

これが私のフォームです。正しく見えるので、これは問題ではありません。また、エンタイプを削除して、そうでないことを確認しました。

    <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」を返します

何か案は?

4

5 に答える 5

8

あなたはこれを試すことができます-

$input = JFactory::getApplication()->input;
$post_array = $input->getArray($_POST);
于 2013-03-31T09:14:20.380 に答える
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)
于 2012-11-23T14:15:16.517 に答える
4

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

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

リクエストから特定の配列(たとえば「jform」と呼ばれる)を取得する場合は、

JFactory::getApplication()->input->get('jform', array(), 'ARRAY');
于 2014-09-29T10:00:56.460 に答える
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');

詳細については、「JInputを使用したリクエストデータの取得」を参照してください。

于 2014-10-30T09:56:33.377 に答える
-2

フォームアクションを次のように変更してみてください。

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

あなたのタスクはhello.createではなくcreateと呼ばれるので、この方法でうまくいくかもしれません。

それから私はいつも

$post = JRequest::get('post');
print_r($post['state']);
于 2012-11-21T21:11:00.307 に答える