protected function add_field(\stdClass $data) {
        foreach ($data->fields as $field) {
            $this->_form->addElement($field);
        }

        if (!empty($data->helps)) {
            foreach ($data->helps as $fieldname => $helpdata) {
                $help = array_merge([$fieldname], $helpdata);
                call_user_func_array([$this->_form, 'addHelpButton'], $help);
            }
        }

        if (!empty($data->types)) {
            foreach ($data->types as $fieldname => $type) {
                $this->_form->setType($fieldname, $type);
            }
        }

        if (!empty($data->rules)) {
            foreach ($data->rules as $fieldname => $ruledata) {
                $rule = array_merge([$fieldname], $ruledata);
                call_user_func_array([$this->_form, 'addRule'], $rule);
            }
        }

        if (!empty($data->defaults)) {
            foreach ($data->defaults as $fieldname => $default) {
                $this->_form($fieldname, $default);
            }
        }
    }