Php 如何在搜索表单上设置默认值?

Php 如何在搜索表单上设置默认值?,php,arrays,wordpress,default-value,Php,Arrays,Wordpress,Default Value,我正在为我的项目wpcasa使用wordpress房地产插件,我已经做了一些修改,但这件事需要我的时间来解决 我认为他们使用数组在搜索表单上获取设置值/标签。 任何人都可以帮助我如何在搜索表单中添加默认值 下面是代码 $defaults = array( 'keyword' => array( 'label' => __( 'Keyword or Listing ID', 'wpcasa' )

我正在为我的项目wpcasa使用wordpress房地产插件,我已经做了一些修改,但这件事需要我的时间来解决

我认为他们使用数组在搜索表单上获取设置值/标签。 任何人都可以帮助我如何在搜索表单中添加默认值

下面是代码

$defaults = array(          
            'keyword' => array(
                'label'         => __( 'Keyword or Listing ID', 'wpcasa' ) . '…',
                'type'          => 'text',
                'class'         => 'width-3-4',
                'priority'      => 10
            ),          
            'submit' => array(
                'label'         => __( 'Search', 'wpcasa' ),
                'type'          => 'submit',
                'class'         => 'width-1-4',
                'priority'      => 20
            ),
            'offer' => array(
                'label'         => __( 'Offer', 'wpcasa' ),
                'key'           => '_price_offer',
                'data'          => wpsight_offers(),
                'type'          => 'select',
                'data_compare'  => '=',
                'class'         => 'width-1-5',
                'priority'      => 30
            ),
            'location' => array(
                'data'          => array(
                    // wp_dropdown_categories() options
                    'taxonomy'          => 'location',
                    'show_option_none'  => __( 'Location', 'wpcasa' ),
                    'option_none_value' => '',
                    'hierarchical'      => 1,
                    'orderby'           => 'ID',
                    'order'             => 'ASC'
                ),
                'type'          => 'taxonomy_select',
                'class'         => 'width-1-5',
                'priority'      => 40
            ),
            'listing-type' => array(
                'data'          => array(
                    // wp_dropdown_categories() options
                    'taxonomy'          => 'listing-type',
                    'show_option_none'  => __( 'Type', 'wpcasa' ),
                    'option_none_value' => '',
                    'hierarchical'      => 1,
                    'orderby'           => 'ID', 
                    'order'             => 'ASC'
                ),
                'type'          => 'taxonomy_select',
                'class'         => 'width-1-5',
                'priority'      => 50
            ),
            $details['details_1']['id'] => array(
                'label'         => $details['details_1']['label'],
                'key'           => '_details_1',
                'data'          => $details['details_1']['data'],
                'type'          => 'select',
                'data_compare'  => '>=',
                'class'         => 'width-1-5',
                'priority'      => 60
            ),
            $details['details_2']['id'] => array(
                'label'         => $details['details_2']['label'],
                'key'           => '_details_2',
                'data'          => $details['details_2']['data'],
                'type'          => 'select',
                'data_compare'  => '>=',
                'class'         => 'width-1-5',
                'priority'      => 70
            )           
        );
`
关键字示例我将设置一个值HOME,而不是显示其标签


谢谢大家!

我现在知道了,我应该加上'default'=>'Myvalue'

范例

'keyword' => array(
                'label'         => __( 'Keyword or Listing ID', 'wpcasa' ) . '…',
                'type'          => 'text',
                'class'         => 'width-3-4',
                'default'       => 'HELLO',
                'priority'      => 10
            ),       

谢谢你的帮助/建议

您已将代码复制了两次。删除其中一个示例。@alexi2找到了,谢谢:)搜索表单上的默认值?占位符?@RajendranNadar值属性不是占位符。确定仅当搜索输入为空时才向其添加值吗?还是取决于页面?我不明白什么时候该添加值属性?