| @@ 59-68 (lines=10) @@ | ||
| 56 | * @param string $label |
|
| 57 | * @param array $fields |
|
| 58 | */ |
|
| 59 | public function __construct($name, $label, $fields) { |
|
| 60 | $this->set_name( $name ); |
|
| 61 | $this->set_label( $label ); |
|
| 62 | $this->add_fields( $fields ); |
|
| 63 | ||
| 64 | // Pick random ID |
|
| 65 | $random_string = md5( mt_rand() . $this->get_name() . $this->get_label() ); |
|
| 66 | $random_string = substr( $random_string, 0, 5 ); // 5 chars should be enough |
|
| 67 | $this->group_id = 'carbon-group-' . $random_string; |
|
| 68 | } |
|
| 69 | ||
| 70 | /** |
|
| 71 | * Add a group of fields. |
|
| @@ 216-227 (lines=12) @@ | ||
| 213 | * @param string $name Field name |
|
| 214 | * @param string $label Field label |
|
| 215 | */ |
|
| 216 | protected function __construct( $name, $label ) { |
|
| 217 | $this->set_name( $name ); |
|
| 218 | $this->set_label( $label ); |
|
| 219 | $this->set_base_name( $name ); |
|
| 220 | ||
| 221 | // Pick random ID |
|
| 222 | $random_string = md5( mt_rand() . $this->get_name() . $this->get_label() ); |
|
| 223 | $random_string = substr( $random_string, 0, 5 ); // 5 chars should be enough |
|
| 224 | $this->id = 'carbon-' . $random_string; |
|
| 225 | ||
| 226 | $this->init(); |
|
| 227 | } |
|
| 228 | ||
| 229 | /** |
|
| 230 | * Boot the field once the container is attached. |
|