Changeset - 023fd0274c40
[Not reviewed]
0 1 0
Jan Kaluza - 10 years ago 2015-11-13 08:29:22
jkaluza@redhat.com
Fix createBooleanField compatibility with swiften2
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/formutils.cpp
Show inline comments
 
@@ -73,97 +73,97 @@ FormField::ref
 
TextPrivateFormField::ref
 
#endif
 
createTextPrivateField(const std::string &name, const std::string &label, bool required) {
 
#if HAVE_SWIFTEN_3
 
	FormField::ref field = boost::make_shared<FormField>(FormField::TextPrivateType);
 
#else
 
	TextPrivateFormField::ref field = TextPrivateFormField::create();
 
#endif
 
	field->setName(name);
 
	field->setLabel(label);
 
	field->setRequired(required);
 
	return field;
 
}
 

	
 
static 
 
#if HAVE_SWIFTEN_3
 
FormField::ref
 
#else
 
ListSingleFormField::ref
 
#endif
 
createListSingleField(const std::string &name, Swift::FormField::Option value, const std::string &label, const std::string &def, bool required) {
 
#if HAVE_SWIFTEN_3
 
	FormField::ref field = boost::make_shared<FormField>(FormField::ListSingleType);
 
#else
 
	ListSingleFormField::ref field = ListSingleFormField::create();
 
#endif
 
	field->setName(name);
 
	field->setLabel(label);
 
	field->addOption(value);
 
#if HAVE_SWIFTEN_3
 
	field->addValue(def);
 
#else
 
	field->setValue(def);
 
#endif
 
	return field;
 
}
 

	
 
static 
 
#if HAVE_SWIFTEN_3
 
FormField::ref
 
#else
 
BooleanFormField::ref
 
#endif
 
createBooleanField(const std::string &name, const std::string &value, const std::string &label, bool required) {
 
#if HAVE_SWIFTEN_3
 
	FormField::ref field = boost::make_shared<FormField>(FormField::BooleanType, value);
 
#else
 
	BooleanFormField::ref field = BooleanFormField::create();
 
	field->setValue(value == "0");
 
	field->setValue(value == "1");
 
#endif
 
	field->setName(name);
 
	field->setLabel(label);
 
	field->setRequired(required);
 
	return field;
 
}
 

	
 
static 
 
#if HAVE_SWIFTEN_3
 
FormField::ref
 
#else
 
FixedFormField::ref
 
#endif
 
createTextFixedField(const std::string &value) {
 
#if HAVE_SWIFTEN_3
 
	FormField::ref field = boost::make_shared<FormField>(FormField::FixedType, value);
 
#else
 
	FixedFormField::ref field = FixedFormField::create(value);
 
#endif
 
	return field;
 
}
 

	
 
void addHiddenField(Form::ref form, const std::string &name, const std::string &value) {
 
	form->addField(createHiddenField(name, value));
 
}
 

	
 
void addTextSingleField(Swift::Form::ref form, const std::string &name, const std::string &value, const std::string &label, bool required) {
 
	form->addField(createTextSingleField(name, value, label, required));
 
}
 

	
 
void addTextPrivateField(Swift::Form::ref form, const std::string &name, const std::string &label, bool required) {
 
	form->addField(createTextPrivateField(name, label, required));
 
}
 

	
 
void addListSingleField(Swift::Form::ref form, const std::string &name, Swift::FormField::Option value, const std::string &label, const std::string &def, bool required) {
 
	form->addField(createListSingleField(name, value, label, def, required));
 
}
 

	
 
void addBooleanField(Swift::Form::ref form, const std::string &name, const std::string &value, const std::string &label, bool required) {
 
	form->addField(createBooleanField(name, value, label, required));
 
}
 

	
 
void addTextFixedField(Swift::Form::ref form, const std::string &value) {
 
	form->addField(createTextFixedField(value));
 
}
 

	
 

	
 
std::string fieldValue(Swift::FormField::ref field) {
0 comments (0 inline, 0 general)