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

时间:2017-10-01 09:11:28

标签: php arrays wordpress default-value

我在我的项目中使用wordpress房地产插件,这是wpcasa,我已经做了一些修改,但这件事花了我的时间来弄明白。

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

这是以下代码

$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
            )           
        );
`

关键字I的示例将设置值HOME而不是显示其标签。

谢谢!

1 个答案:

答案 0 :(得分:0)

我现在知道了我应该添加'默认' => ' myvalue的',

例如

SELECT CASE WHEN t.name = 'numeric' 
            THEN CAST(c.precision AS varchar(100)) +')'
       END
FROM sys.columns c 
INNER JOIN sys.types t ON t.user_type_id = c.user_type_id
INNER JOIN sys.tables tb ON tb.object_id = c.object_id
WHERE c.name = 'B_CODE'
AND tb.name = 'EX_EMPLOYEE'

感谢您的帮助/建议!

相关问题