从 Gravity Forms 表单对象获取单选按钮文本值
Get radio button text value from Gravity Forms form object
我在这里剥离 GF 表单对象的结构:
$form =
array(22)
{
["fields"]=> array(2)
{
[1]=> object(GF_Field_Radio)#1732 (40)
{
["choices"]=> array(2)
{
[0]=> array(4)
{
["text"]=> string(12) "First Choice"
}
[1]=> array(4)
{
["text"]=> string(13) "Second Choice"
}
}
}
}
}
我想将 'First Choice' 放入我的 $label 变量中。我知道这是不正确的:
$label = $form['fields'][1]['choices'][0]['text'];
我怎样才能拿到那件物品?
我的解决方案
$field_id = 4;
$field = GFFormsModel::get_field( $form, $field_id );
$choice_text = $field['choices'][$entry[$field_id]]['text'];
$data = $choice_text;
我在这里剥离 GF 表单对象的结构:
$form =
array(22)
{
["fields"]=> array(2)
{
[1]=> object(GF_Field_Radio)#1732 (40)
{
["choices"]=> array(2)
{
[0]=> array(4)
{
["text"]=> string(12) "First Choice"
}
[1]=> array(4)
{
["text"]=> string(13) "Second Choice"
}
}
}
}
}
我想将 'First Choice' 放入我的 $label 变量中。我知道这是不正确的:
$label = $form['fields'][1]['choices'][0]['text'];
我怎样才能拿到那件物品?
我的解决方案
$field_id = 4;
$field = GFFormsModel::get_field( $form, $field_id );
$choice_text = $field['choices'][$entry[$field_id]]['text'];
$data = $choice_text;