called form <<, append, and create.  If a hash is passed in, it converts
 it to a model.  Then it takes the model and inserts it into the ArrayModel
 then persists it.
767041
def create_new_model(model, from_method)
      if model.is_a?(Model)
        if model.buffer?
          fail "The #{from_method} does not take a buffer.  Call .save! on buffer's to persist them."
        end

        # Set the new path and the persistor.
        model.options = @options.merge(parent: self, path: @options[:path] + [:[]])
      else
        model = wrap_values([model]).first
      end


      if model.is_a?(Model)
        promise = model.can_create?.then do |can_create|
          unless can_create
            fail "permissions did not allow create for #{model.inspect}"
          end
        end.then do

          # Add it to the array and trigger any watches or on events.
          reactive_array_append(model)

          @persistor.added(model, @array.size - 1)
        end.then do
          nil.then do
            # Validate and save
            model.run_changed
          end.then do
            # Mark the model as not new
            model.instance_variable_set('@new', false)

            # Mark the model as loaded
            model.change_state_to(:loaded_state, :loaded)

          end.fail do |err|
            # remove from the collection because it failed to save on the server
            # we don't need to call delete on the server.
            index = @array.index(model)
            delete_at(index, true)

            # remove from the id list
            @persistor.try(:remove_tracking_id, model)

            # re-raise, err might not be an Error object, so we use a rejected promise to re-raise
            Promise.new.reject(err)
          end
        end
      else
        promise = nil.then do
          # Add it to the array and trigger any watches or on events.
          reactive_array_append(model)

          @persistor.added(model, @array.size - 1)
        end
      end

      promise = promise.then do
        # resolve the model
        model
      end

      # unwrap the promise if the persistor is synchronus.
      # This will return the value or raise the exception.
      promise = promise.unwrap unless @persistor.async?

      # return
      promise
    end
884178
def hash_to_model(klass_name, hash)
      model_klass =
        if self.class.const_defined?("#{self.class}::#{klass_name}")
          self.class.const_get(klass_name)
        else
          self.class.const_set(klass_name, Class.new(HashModel))
        end
      model_klass.new(hash)
    end
1127047
function( a ) {
		var s = [ ];

		function add( key, value ){
			s[ s.length ] = encodeURIComponent(key) + '=' + encodeURIComponent(value);
		};

		// If an array was passed in, assume that it is an array
		// of form elements
		if ( jQuery.isArray(a) || a.jquery )
			// Serialize the form elements
			jQuery.each( a, function(){
				add( this.name, this.value );
			});

		// Otherwise, assume that it's an object of key/value pairs
		else
			// Serialize the key/values
			for ( var j in a )
				// If the value is an array then the key names need to be repeated
				if ( jQuery.isArray(a[j]) )
					jQuery.each( a[j], function(){
						add( j, this );
					});
				else
					add( j, jQuery.isFunction(a[j]) ? a[j]() : a[j] );

		// Return the resulting serialization
		return s.join("&").replace(/%20/g, "+");
	}
856322
function prepareFormData() {

            var data = {},
                matches,
                index;

            for (var i in formData) {
                if (!formData.hasOwnProperty(i)) continue;

                index = 0;
                matches = i.split(/\[(.+?)]/g);

                var tmpObject = {},
                    tmpArray = [];

                for (var k = matches.length - 1; k >= 0; k--) {
                    if (matches[k] === "") {
                        matches.splice(k, 1);
                        continue;
                    }

                    if (tmpArray.length < 1) {
                        tmpObject[matches[k]] = Number(formData[i]) || formData[i];
                    } else {
                        tmpObject = {};
                        tmpObject[matches[k]] = tmpArray[tmpArray.length - 1];
                    }
                    tmpArray.push(tmpObject)

                }

                data = $.extend(true, data, tmpObject);

            }

            formData = data;

        }
348419
def save_new(self, form, commit=True):
        
        kwargs = {self.fk.get_attname(): self.instance.pk}
        new_obj = self.model(**kwargs)
        self._prepare_multilingual_object(new_obj, form)
        return forms.save_instance(form, new_obj, exclude=[self._pk_field.name], commit=commit)
118410
def save
            unless [ :handle, :new, :modify, :save ].all?{|method| api_methods[method] }
                raise "Not all necessary api methods are defined to process this action!"            
            end
            entry = self.class.find_one(name)
            self.class.in_transaction(true) do |token|
                if entry
                    entryid = self.class.make_call(api_methods[:handle],name,token) 
                else
                    entryid = self.class.make_call(api_methods[:new],token)
                    self.class.make_call(api_methods[:modify],entryid,'name', name, token)
                end
                
                cobbler_record_fields.each do |field|
                    field_s = field.to_s
                    if !locked_fields.include?(field) && user_definitions.has_key?(field_s)
                        self.class.make_call(api_methods[:modify],entryid,field_s, user_definitions[field_s], token)
                    end
                end
                
                cobbler_collections_store_callbacks.each do |callback|
                    send(callback,entryid,token)
                end
                
                self.class.make_call(api_methods[:save],entryid,token)
            end
        end
723826
@SuppressWarnings({ "unchecked", "rawtypes" })
	protected Form<?> newForm(final String id,
		final IModel<? extends BaseUsernameSignUpModel> model)
	{
		return new Form(id, model);
	}
688654
def save_existing(self, form, instance, commit=True):
        
        self._prepare_multilingual_object(instance, form)
        return forms.save_instance(form, instance, exclude=[self._pk_field.name], commit=commit)
1079413
def nested_form_for_main_fields(klass, nested_klass, options={})
      form_for_main_fields(klass,options) do |form_field|
        nested_table_name = nested_klass.to_s.underscore.pluralize.to_sym
        main_model_name = klass.to_s.underscore.to_sym
        form_field.has_many nested_table_name, allow_destroy: true do |form|
          nested_klass.main_fields.map { |f| ExtensionedSymbol.new(f).cut_id }.each do |nested_field|
            current_options = options.fetch(nested_table_name){{}}.fetch(nested_field){{}}
            form.input(nested_field, current_options) unless nested_field == main_model_name
          end
        end
      end
    end
833815
public function add()
    {
        $this->view = 'scaffold/add';
        $form = new Form(
            "add-{$this->get('modelSingular')}", $this->getDescriptor()
        );
        if ($this->request->isPost()) {
            $form->setData($this->request->getPost());
            if ($form->isValid()) {
                try {
                    $modelClass = $this->getModelName();
                    /** @var Model $model */
                    $model = new $modelClass($form->getValues());
                    $model->save();
                    $name = ucfirst($this->get('modelSingular'));
                    $this->addSuccessMessage(
                        "{$name} successfully created."
                    );
                    $pmk = $model->getPrimaryKey();
                    $this->redirect(
                        $this->_basePath .'/'.
                        $this->get('modelPlural').'/show/'.$model->$pmk
                    );
                    return;
                } catch (Database\Exception $exp) {
                    $this->addErrorMessage(
                        "Error while saving {$this->get('modelSingular')}} " .
                        "data: {$exp->getMessage()}"
                    );
                }
            } else {
                $this->addErrorMessage(
                    "Cannot save {$this->get('modelSingular')}. " .
                    "Please correct the errors bellow."
                );
            }
        }
        $descriptor =  $this->getDescriptor();
        $this->set(compact('form', 'descriptor'));
    }
483245
def <<(obj)
      if obj.is_a?(Integer)
        push_int(obj)
      elsif obj.is_a?(String)
        append_data(obj)
      elsif obj.is_a?(Array)
        obj.each { |o| self.<< o}
        self
      end
    end
362630
def create(attributes_hash)
      #the tap method allows preconfigured methods and values to
      #be associated with the instance during instantiation while also automatically returning
      #the object after its creation is concluded.
      self.new.tap do |card|
        attributes_hash.each do |key, value|
          #sending the new instance the key name as a setter with the value
          card.send("#{key}=", value)
          #string interpolation is used as the method doesn't know the key name yet
          #but an = sign is implemented into the string in order to asssociate it as a setter
        end
        #saves the new instance into the database
        card.save
      end
    end
183969
public FormDataBuilder form(String key, Object value) {
        datas.put(key, value == null ? "" : value);
        return this;
    }
16083
function(model_s, create, options){
      var toAdd = model_s instanceof Array ? model_s : [model_s],
          self = this;

      ko.utils.arrayForEach(toAdd, function(attributes){
        var model;
        if(attributes instanceof Model){
          model = attributes;
          model.collection = self;
        }else{
          model = new self.model(attributes, {collection: self});
        }
        self.models.push(model);
        if(create) model.save(options);
      });
    }
982947
def put(url, params)
      params = convert_hash_keys(params)
      preform(url, :put, params: params) do
        return connection.put(url, params)
      end
    end
145593
function newInstance (controller, args) {
    // get model from controller
    var model = controller.model
    // form to create new instance
    var form
    // get model data from input
    var data = args[model.name]
    // if pre-fill input is passed then initialize form with it
    if (defined(data)) {
        form = controller.form.newInstance({
            input: data,
            redirect: args.redirect,
        })
    }
    // otherwise use default form
    else {
        form = controller.form.newInstance({
            action: './?redirect=./',
        })
    }

    return {
        form: form,
    }
}
268189
function append(form_id, array_name, value) {
        this._checkInit(form_id);
        var formData = this._collection[form_id];
        formData.append(array_name, value);
    }