Search Results

Search found 6519 results on 261 pages for 'nested attributes'.

Page 6/261 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • How do I get my custom requiredif attribute to prevent other attributes from firing

    - by user1757804
    I'm working on an MVC application. I've decorated a property with EqualTo found here: http://dataannotationsextensions.org/EqualTo/Create As well as a custom RequiredIf attribute as suggested here: http://blogs.msdn.com/b/simonince/archive/2011/02/04/conditional-validation-in-asp-net-mvc-3.aspx My issue is that even when the field is supposed to be required and isn't the EqualTo logic is firing. So I get error messages saying the field is required but also that the field doesn't match. If I replace the Requiredif with a regular Required only the Required message will show. What I'm trying to figure out is how the EqualTo logic is prevented when combined with the Required attribute but not prevented when combined with my custom RequiredIf. Any suggestions would be most appreciated, I've been racking my brain most of the day trying to figure out the mvc internals around Required.

    Read the article

  • Python. Strange class attributes behavior

    - by Eugene
    >>> class Abcd: ... a = '' ... menu = ['a', 'b', 'c'] ... >>> a = Abcd() >>> b = Abcd() >>> a.a = 'a' >>> b.a = 'b' >>> a.a 'a' >>> b.a 'b' It's all correct and each object has own 'a', but... >>> a.menu.pop() 'c' >>> a.menu ['a', 'b'] >>> b.menu ['a', 'b'] How could this happen? And how to use list as class attribute?

    Read the article

  • Creating attribute sets and attributes programatically magento

    - by digital_paki
    I am using the code listed on the following link =: http://www.magentocommerce.com/wiki/5_-_modules_and_development/catalog/programmatically_adding_attributes_and_attribute_sets Everything works until the point: // Just add a default group. else { $this->logInfo("Creating default group [{$this->groupName}] for set."); $modelGroup = Mage::getModel('eav/entity_attribute_group'); $modelGroup->setAttributeGroupName($this->groupName); $modelGroup->setAttributeSetId($id); // This is optional, and just a sorting index in the case of // multiple groups. // $modelGroup->setSortOrder(1); $model->setGroups(array($modelGroup)); } I am unsure where the object reference would need to be set from - I am attempting to have this as a separate file that can be automated - I am running this file by doing a require_once 'app/Mage.php'; Mage::app(); Any help in this would be greatly appreciated Thanks

    Read the article

  • Using variables within Attributes in C#

    - by tehp
    We have some Well-Attributed DB code, like so: [Display(Name = "Phone Number")] public string Phone { get; set; } Since it is quite generic we'd like to use it again, but with a different string in the Name part of the attribute. Since it's an attribute it seems to want things to be const, so we tried: const string AddressType = "Student "; [Display(Name = AddressType + "Phone Number")] public string Phone { get; set; } This seems to work alright, except that having a const string means we can't overwrite it in any base classes, thereby removing the functionality that we originally were intending to add, and exposing my question: Is there a way to use some sort of variable inside of an attribute so that we can inherit and keep the attribute decorations?

    Read the article

  • Can C# Attributes access the Target Class?

    - by Heka
    I want to access the properties of a class from the attribute class by using reflection. Is it possible? For example: class MyAttribute : Attribute { private void AccessTargetClass() { // Do some operations } } [MyAttribute] class TargetClass { }

    Read the article

  • Setting the value of textboxes with one of their attributes (jQuery)

    - by Jimbo
    I have a bunch of input text boxes that have the attribute ORIGINAL set to their initial value, so that when the user changes the textbox value, jQuery can highlight items that have changed (by comparing the text box's current value to the ORIGINAL attribute's value) What Im trying to do now is provide the user with a button that they can click to revert all text boxes back to their original values based on the value of the ORIGINAL attribute of each text box. Example $('input[type=text]').val($(this).attr('original')); The above doesnt work and I dont understand why.

    Read the article

  • custom attribute changes in .NET 4

    - by Sarah Vessels
    I recently upgraded a C# project from .NET 3.5 to .NET 4. I have a method that extracts all MSTest test methods from a given list of MethodBase instances. Its body looks like this: return null == methods || methods.Count() == 0 ? null : from method in methods let testAttribute = Attribute.GetCustomAttribute(method, typeof(TestMethodAttribute)) where null != testAttribute select method; This worked in .NET 3.5, but since upgrading my projects to .NET 4, this code always returns an empty list, even when given a list of methods containing a method that is marked with [TestMethod]. Did something change with custom attributes in .NET 4? Debugging, I found that the results of GetCustomAttributesData() on the test method gives a list of two CustomAttributeData which are described in Visual Studio 2010's 'Locals' window as: Microsoft.VisualStudio.TestTools.UnitTesting.DeploymentItemAttribute("myDLL.dll") Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute() -- this is what I'm looking for When I call GetType() on that second CustomAttributeData instance, however, I get {Name = "CustomAttributeData" FullName = "System.Reflection.CustomAttributeData"} System.Type {System.RuntimeType}. How can I get TestMethodAttribute out of the CustomAttributeData, so that I can extract test methods from a list of MethodBases?

    Read the article

  • Generate multiple attribute?

    - by acidzombie24
    ATM i cant quiet imagine how this will work. I'm sure it can be done. I notice a pattern use in my attribute where i always use 3 specific attributes together. Take the below as an example [MyAttr(4, @"a"), MyAttr(41, "b"), MyAttr(45, "ab")] Mine is much more complicated but i would like to define one attribute with more params to generate the data above. How might i do that? Lets say my one attribute will look like this MyAttr2(4, 41, "a", "b"); //4+41=45, "a"+"b" = "ab" How might i generate the 3 MyAttr to apply to a class using MyAttr2?

    Read the article

  • How to add and remove nested model fields dynamically using Haml and Formtastic

    - by Brightbyte8
    We've all seen the brilliant complex forms railscast where Ryan Bates explains how to dynamically add or remove nested objects within the parent object form using Javascript. Has anyone got any ideas about how these methods need to be modified so as to work with Haml Formtastic? To add some context here's a simplified version of the problem I'm currently facing: # Teacher form (which has nested subject forms) [from my application] - semantic_form_for(@teacher) do |form| - form.inputs do = form.input :first_name = form.input :surname = form.input :city = render 'subject_fields', :form => form = link_to_add_fields "Add Subject", form, :subjects # Individual Subject form partial [from my application] - form.fields_for :subjects do |ff| #subject_field = ff.input :name = ff.input :exam = ff.input :level = ff.hidden_field :_destroy = link_to_remove_fields "Remove Subject", ff # Application Helper (straight from Railscasts) def link_to_remove_fields(name, f) f.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)") end def link_to_add_fields(name, f, association) new_object = f.object.class.reflect_on_association(association).klass.new fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder| render(association.to_s.singularize + "_fields", :f => builder) end link_to_function(name, h("add_fields(this, \"#{association}\", \"#{escape_javascript(fields)} \")")) end #Application.js (straight from Railscasts) function remove_fields(link) { $(link).previous("input[type=hidden]").value = "1"; $(link).up(".fields").hide(); } function add_fields(link, association, content) { var new_id = new Date().getTime(); var regexp = new RegExp("new_" + association, "g") $(link).up().insert({ before: content.replace(regexp, new_id) }); } The problem with implementation seems to be with the javascript methods - the DOM tree of a Formtastic form differs greatly from a regular rails form. I've seen this question asked online a few times but haven't come across an answer yet - now you know that help will be appreciated by more than just me! Jack

    Read the article

  • How to fill DataGridView from nested table oracle

    - by arkadiusz85
    I want to create my type: CREATE TYPE t_read AS OBJECT ( id_worker NUMBER(20), how_much NUMBER(5,2), adddate_r DATE, date_from DATE, date_to DATE ); I create a table of my type: CREATE TYPE t_tab_read AS TABLE OF t_read; Next step is create a table with my type: enter code hereCREATE TABLE Reading ( id_watermeter NUMBER(20) constraint Watermeter_fk1 references Watermeters(id_watermeter), read t_tab_read ) NESTED TABLE read STORE AS store_read ; Microsoft Visual Studio can not display this type in DataGridView. I use Oracle.Command: C# using Oracle.DataAccess; using Oracle.DataAccess.Client; private void button1_Click(object sender, EventArgs e) { try { //my working class to connect to database ConnectionClass.BeginConnection(); OracleDataAdapter tmp = new OracleDataAdapter(); tmp = ConnectionClass.ReadCommand(ReadClass.test()); DataSet dataset4 = new DataSet(); tmp.Fill(dataset4, "Read1"); dataGridView4.DataSource = dataset4.Tables["Read1"]; } catch (Exception o) { MessageBox.Show(o.Message); } public class ReadClass { public static OracleCommand test() { string sql = "select c.id_watermeter, a. from reading c , table (c.read) a where id_watermeter=1"; ConnectionClass.Command1= new OracleCommand(sql, ConnectionClass.Connection); ConnectionClass.Command1.CommandType = CommandType.Text; return ConnectionClass.Command1; } } I tray: string sql = "select r.id_watermeter, o.id_worker, o.how_much, o.adddate_r, o.date_from, o.date_to from reading r, table (r.read) o where r.id_watermeter=1" string sql = "select a.from reading c , Table (c.read) a where id_watermeter=1" string sql = "select a.id_worker, a.how_much, a.adddate_r, a.date_from, a.date_to from reading c , table (c.read) a where id_watermeter=1" string sql = "select c.id_watermeter, a. from reading c , table (c.read) a where id_watermeter=1" Error : Unsuported Oracle data type USERDEFINED encountered Sombady can help me how to fill DataGridView using data from nested table. I am using Oracle 10g XE

    Read the article

  • problems with build params for accepts_nested_attributes_for

    - by holden
    I'm trying to add the user_id to a nested attribute that gets built by a parent controller but it doesn't seem to have the desired effect? Ie. I have a model called Place.rb which accepts_nested_attributes_for :reviews The nested attribute works fine and I build it inside the Places controller like so... @review = @place.reviews.build(:user_id => current_user.id) I was previously adding the user thru the form, but would like to do it thru the controller so that it only adds the user_id on creation, as it might get updated by someone else and i don't want the update changing the user_id... old way which works: <%= e.label :content, "Review" %><br /> <%= e.text_area :content, :rows => 20, :class => 'jquery_ckeditor' %><br /> <%= e.hidden_field :user_id, :value => current_user.id %> but thru the controller the build method with options has no effect? Any ideas? Can I not do this thru the build?

    Read the article

  • Convert a nested array into a flat array with PHP

    - by Ben Fransen
    Hello all, I'm trying to create a generic database mapping class with PHP. Collecting the data through my functions is going well, but as expected I'm retrieving a nested set. A print_r of my received array looks like: Array ( [table] => Session [columns] => Array ( [0] => `Session`.`ID` AS `Session_ID` [1] => `Session`.`User` AS `Session_User` [2] => `Session`.`SessionID` AS `Session_SessionID` [3] => `Session`.`ExpiresAt` AS `Session_ExpiresAt` [4] => `Session`.`CreatedAt` AS `Session_CreatedAt` [5] => `Session`.`LastActivity` AS `Session_LastActivity` [6] => `Session`.`ClientIP` AS `Session_ClientIP` ) [0] => Array ( [table] => User [columns] => Array ( [0] => `User`.`ID` AS `User_ID` [1] => `User`.`UserName` AS `User_UserName` [2] => `User`.`Password` AS `User_Password` [3] => `User`.`FullName` AS `User_FullName` [4] => `User`.`Address` AS `User_Address` ) [0] => Array ( [table] => Address [columns] => Array ( [0] => `Address`.`ID` AS `Address_ID` [1] => `Address`.`UserID` AS `Address_UserID` [2] => `Address`.`Street` AS `Address_Street` [3] => `Address`.`City` AS `Address_City` ) ) ) ) To simplify things I want to recreate this nested array to a flat array so I can easily loop through it and use the 'columns' key to create my SELECT query. I'm kinda struggling with this for a while now and figures, maybe some users at SO can help me out here. I've tried multiple things with recursion, all without luck so far... Any help is much appriciated! Thanks in advance, Ben Fransen

    Read the article

  • Types of Nested Loops in JAVA

    - by dominoos
    Hi guys. I have a simple question. I have to find out many nested loops as possible in java. I have something like for loop and if statement inside. i know that we can do like if{if{if{if{ something like that too. just need some more idea of more types of nested loops. if you can write down some examples. I'll be very glad. thank you. public class Test { public static void main (String []args) { int i = 0; for(int j = 1; j <= 5; j++) { if(j == 1 || j == 5) { i = 4; } else { i = 1; } for(int x = 0; x < i; x++) { System.out.print("**"); } System.out.println(); } } }

    Read the article

  • DRYing up Rails Views with Nested Resources

    - by viatropos
    What is your solution to the problem if you have a model that is both not-nested and nested, such as products: a "Product" can belong_to say an "Event", and a Product can also just be independent. This means I can have routes like this: map.resources :products # /products map.resources :events do |event| event.resources :products # /events/1/products end How do you handle that in your views properly? Note: this is for an admin panel. I want to be able to have a "Create Event" page, with a side panel for creating tickets (Product), forms, and checking who's rsvp'd. So you'd click on the "Event Tickets" side panel button, and it'd take you to /events/my-new-event/tickets. But there's also a root "Products" tab for the admin panel, which could list tickets and other random products. The 'tickets' and 'products' views look 90% the same, but the tickets will have some info about the event it belongs to. It seems like I'd have to have views like this: products/index.haml products/show.haml events/products/index.haml events/products/show.haml But that doesn't seem DRY. Or I could have conditionals checking to see if the product had an Event (@product.event.nil?), but then the views would be hard to understand. How do you deal with these situations? Thanks so much.

    Read the article

  • Created nested model setting a property on nested model before save

    - by CWitty
    I have two models a Company and a User the Company has_many :users and the User belongs_to :company. I have a form such as: <%= form_for @company, data: {toggle: :validator}, novalidate: "novalidate", html: {role: :form} do |f| %> company fields Then in there I have <%= f.fields_for :users, @company.users.build do |user_form| %> A bunch of user fields It posts the data with the nested attributes of users_attributes: {"0" => {name: "Chad"}} But it doesn't create the user only the company object. Company Model class Company < ActiveRecord::Base has_many :users, dependent: :destroy has_many :contacts, dependent: :destroy accepts_nested_attributes_for :users accepts_nested_attributes_for :contacts attr_accessor :card_token, :users_attributes before_create :create_company_customer_token before_create :create_admin_user before_destroy :set_deleted_flag validates_presence_of :name, :phone_number private def create_admin_user self.users.first.admin = true end def set_deleted_flag self.deleted = true save users.each do |u| u.destroy end false end def create_company_customer_token begin customer = Stripe::Customer.create(description: "Company: #{self.name}", card: self.card_token, plan: self.plan) self.stripe_customer_id = customer['id'] rescue Stripe::StripeError => e self.errors.add(:stripe_customer_id, "Looks like we are having an issue at the moment, please try again shortly") @logger ||= Rails.logger @logger.error(e) end end end User Model class User < ActiveRecord::Base include Clearance::User has_many :messages belongs_to :company before_destroy :set_deleted_flag after_create :send_welcome_email validates_presence_of :first_name, :last_name validates_uniqueness_of :email, scope: :company_id, conditions: -> { where.not(deleted: true) } def name "#{first_name} #{last_name}" end private def set_deleted_flag self.deleted = true save end def send_welcome_email UserMailer.welcome_email(self).deliver end end

    Read the article

  • ASP.NET Nested masterpages, how to set content in the top page from the aspx file?

    - by David Suarez
    I have some content from a CMS that I need to move to raw asp.net pages. Since the templates are nested I guess I can use nested masterpages to acomplish it, but I'm finding that I can't set values on the top masterpage from the deep child page. Here is a sample. I have several nested masterpages with contentplaceholders: top master (with contentPlaceHolder1) nested master, dependent on top master (with contentPlaceHolder2) aspx page, dependent on nested master, defines content for contentPlaceHolder1 and 2 The problem is that asp.net doesn't allow me to have the value of contentPlaceHolder1 defined in the content page, it should be defined in the nested master. But the point is that the client page knows that value, not the template masters (for instance, the page knows about the graphic it has to display on the the top, but the placeholder for the graphic is the top master). How can I set values in the aspx page to be rendered in the top master?

    Read the article

  • .NET custom property attribute?

    - by ropstah
    EDIT: I'd better rephrase: How can I shift the GET-implementation of a Class property to a / using a custom attribute? (I've added instantation vars (classname, propertyname) to the attribute, however I'd rather have these automatically fetched ofcourse.) Public Class CustomClass <CustomAttributeClass(ClassName:="CustomClass", PropertyName = "SomeProperty")> _ Public Property SomeProperty() as String Get() as String //This implementation should be handled by the attribute class End Get Set(Byval value as String) Me._someProperty = value End Set End Property End Class Old question: I want to create a custom property attribute for classes. I can create a class derived from Attribute, and 'mark' the property with the attribute, but where to go from here? I have a repository where I can quickly get data based on the attributes values. I would like to generalize the behaviour of the property in the attribute but I don't know how to go from here... Any help would be greatly accepted! Public Class CustomDataAttribute : Inherits Attribute Private _name As String Public Sub New(ByVal name As String) Me.Name = name End Sub Property Name() As String Get Return _name End Get Set(ByVal value As String) Me._name = value End Set End Property End Class Public Class CustomClass <CustomDataAttribute(Name:="CustomField")> _ Public Property CustomField() End Property End Class

    Read the article

  • Nested Threads?

    - by Olaseni
    What are the rules regarding spawning new threads within other running threads? I have a C# app that handles two basic threads in the background. I recently introduced some heavy duty IO stuff, and I was thinking of setting them off inside threads. Are threads nested within themselves cool?

    Read the article

  • jQuery nested sortables jumpy behaviour

    - by sebbie
    I want to allow user to drag and drop UI elements. I've 'container' and 'control', control may be in container, containers may include other containers (this is important requirement). I created simple prototype using jQuery. HTML: <div class="one"> <div class="control">Control 1</div> <div class="control">Control 2</div> <div class="control container"> Container drag area <div class="control">Subcontrol 1</div> <div class="control">Subcontrol 2</div> <div class="control">Subcontrol 3</div> <div class="control">Subcontrol 4</div> <div class="control">Subcontrol 5</div> <div class="control">Subcontrol 6</div> <div class="control">Subcontrol 7</div> <div class="control">Subcontrol 8</div> <div class="control">Subcontrol 9</div> </div> <div class="control">Control 3</div> Then I created sortables using jQueryUI: $('.one').sortable({ items: 'div.control', placeholder: 'placeholder', forcePlaceholderSize: true }); Now when I'm trying to drag "Subcontrol 8" and place it between "Subcontrol 2" and "Subcontrol 3" for example I'm getting jumpy effect, you can observe it here: http://jsbin.com/egipu4/2 Interesting thing is - when I remove ability to drag "container" then it becomes smooth and perfect (you can see this on jsbin example below "jumpy" example, you can't drag using "Container drag area" span). I tried different "nested" plugins and techniques, google'd for a long time and the only one that worked was on this page: (StackOverflow doesn't allow me to post more than one like, google for "Brian Swartzfager's Blog: Nested List Sort Demo" should be first, sorry!) But it does work great only in jQuery1.2 and very old jQueryUI. If I include latest jQuery (1.3/1.4) and UI (1.7/1.8) it gets jumpy as well. What am I doing wrong?

    Read the article

  • Python - Nested List to Tab Delimited File?

    - by Seafoid
    Hi, I have a nested list comprising ~30,000 sub-lists, each with three entries, e.g., nested_list = [['x', 'y', 'z'], ['a', 'b', 'c']]. I wish to create a function in order to output this data construct into a tab delimited format, e.g., x y z a b c Any help greatly appreciated! Thanks in advance, Seafoid.

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >