Browse Source

Read only attribute support, closing #13

master
Artyom Beilis 11 years ago
parent
commit
6007fa5bad
2 changed files with 27 additions and 1 deletions
  1. +13
    -1
      cppcms/form.h
  2. +14
    -0
      src/form.cpp

+ 13
- 1
cppcms/form.h View File

@@ -533,6 +533,17 @@ namespace cppcms {
///
void disabled(bool);


///
/// Get the HTML \c readonly attribute.
///
bool readonly();

///
/// Set/Unset the HTML \c readonly attribute.
///
void readonly(bool);

///
/// Get the general user defined attribute string that can be added to the widget.
///
@@ -685,11 +696,12 @@ namespace cppcms {
uint32_t is_valid_ : 1;
uint32_t is_set_ : 1;
uint32_t is_disabled_ : 1;
uint32_t is_readonly_ : 1;
uint32_t is_generation_done_ : 1;
uint32_t has_message_ : 1;
uint32_t has_error_ : 1;
uint32_t has_help_ : 1;
uint32_t reserverd_ : 25;
uint32_t reserverd_ : 24;

struct _data;
booster::hold_ptr<_data> d;


+ 14
- 0
src/form.cpp View File

@@ -277,6 +277,7 @@ base_widget::base_widget() :
is_valid_(1),
is_set_(0),
is_disabled_(0),
is_readonly_(0),
is_generation_done_(0),
has_message_(0),
has_error_(0),
@@ -408,6 +409,16 @@ void base_widget::disabled(bool v)
is_disabled_=v;
}

bool base_widget::readonly()
{
return is_readonly_;
}

void base_widget::readonly(bool v)
{
is_readonly_=v;
}

std::string base_widget::attributes_string()
{
return attr_;
@@ -673,6 +684,9 @@ void text::render_attributes(form_context &context)
if(lm.second >= 0 && validate_charset()) {
output << "maxlength=\"" << cint(lm.second) << "\" ";
}
if(readonly()) {
output << "readonly=\"readonly\" ";
}
}




Loading…
Cancel
Save